small medium large xlarge

26 Jun 2017, 11:30
peter boone (1 post)

I’m having trouble trying out this function in IDLE. How do I get the 4 print statements with the different fahrenheit values to run?

Keep getting this error message…

SyntaxError: multiple statements found while compiling a single statement

27 Jun 2017, 10:51
Jennifer Campbell (17 posts)

It sounds like there may be a spacing or indentation problem. It can be a bit hard to judge spacing within IDLE’s Python Shell. One option would be to get the code organized in a text editor with the correct spacing and then copy and paste it to IDLE. I’ve provided the code below, in case that helps.

def convert_to_celsius(fahrenheit): 
    """ (number) -> float
    Return the number of Celsius degrees equivalent to fahrenheit degrees.
    >>> convert_to_celsius(75)
    return (fahrenheit - 32.0) * 5.0 / 9.0

print('80, 78.8, and 10.4 degrees Fahrenheit are equal to ', end='') 
print(convert_to_celsius(80), end=', \n') 
print(convert_to_celsius(78.8), end=', and ') 
print(convert_to_celsius(10.4), end=' Celsius.\n')

You may also find it helpful to use an editor that offers a few more features than IDLE. A nice free option is Wing 101 IDE.

You must be logged in to comment