What I'm trying to accomplish is to ask the user for a number and then print a countdown from that number to zero.
This is what i got so far.
#Ask user for a number
n = raw_input ("Enter a number:")
# print countdown of n
def countdown (n):
while n > 0:
print n
n = n-1
if n < 0:
print "Enter a Positive Number" # in case user try to enter a negative number (It seems to work)
else:
n = raw_input("Enter a number:") # If the user input a negative number, a "Enter a number" question should be ask again. I'm not sure if this is the correct way to do it ( please advise for a better way)
- once i enter the number, the program doesn't print the countdown. Please let me know what am I doing wrong
- I'm not asking for you to fix this code for me, but to give some examples in a way i can resolve and improved my code
- Thanks in advanced for your time and help!!!!

New Topic/Question
Reply



MultiQuote








|