Ask your own question, for FREE!
Loops 7 Online
OpenStudy (amkgoldie):

Trying Blastoff activity from Chapter 4. See below, have only added input prompt. Does not work. n = input("input ") def countdown(n): if n == 0: print "Blastoff!" else: print n countdown(n-1)

OpenStudy (reemii):

You have to call the `countdown` function at least once. ``` def countdown(n): if n == 0: print "Blastoff!" else: print n countdown(n-1) n = input("input ") countdown(n) # Call the function otherwise nothing happens ```

OpenStudy (rsmith6559):

The syntax of your print statement suggests that this is Python v2.x. In v2, use raw_input() instead: n = int( raw_input( "input " ) ) BTW, raw_input() returns a string, that's why it's surrounded by the int() function, to convert what was typed to an int. If this is Python v3, then your print statement is wrong. Print returned to being a function in v3: print( n ) FYI, congratulations on writing this recursively! Hold onto the code for later in your course.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!