1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Basic python help?

  1. Oct 7, 2011 #1
    Im having trouble with a basic python assignment in one of my classes. Its supposed to ask the user for temperatures in Celsius and convert them to Fahrenheit, which it does fine. The problem is that its also supposed stop asking the user if he gives it 0, which means the end of the list of numbers. My program converts fine, but upon entering 0 it just gives me 32, which means something is wrong with my if statement and its just converting 0 like a normal number. Any help? here is my code.

    count = 1
    converted = False
    while (converted == False):
    Celsius = raw_input("Temperature number " + str(count) + " to be converted?: ")
    if (Celsius.rstrip() == 0):
    converted = True​
    Celsius = int(Celsius.rstrip()) * 1.8 + 32
    print (Celsius)
    count = count + 1​
     
  2. jcsd
  3. Oct 8, 2011 #2

    NascentOxygen

    User Avatar

    Staff: Mentor

    I use Python. Can you explain what this portion of code does?

    if (Celsius.rstrip() == 0):
    converted = True
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Basic python help?
  1. CSC131 Python Help (Replies: 6)

Loading...