I need to make this code work in this way. When a negative number is give (-3) it should count up -3, -2, -1, 0, Blastoff!
The code only counts down to 0 from a positive number and when a negative number is given, it only prints "Blastoff!"
My initial thought was to change "<" to a ">" in the second function but didn't do anything.
Also, I need to make it in such a way that when I enter 0, it would count up in pairs instead when number 0 is given, it breaks the program as a whole.
Please help, just remember you are talking to a newbie.
This is a home practice exercise and I have tried to do it but cant figure it out, and haven't found anything in YouTube or here to explain the procedure in python.
n = int(input("Please enter a number: "))
def countdown(n):
if n <= 0:
print('Blastoff!')
else:
print(n)
countdown(n-1)
countdown(n)
def countup(n):
for n in range(0, -100000):
if n >= 0:
print ( "Blastoff! ")
else:
print (n)
countup (n+1)
countup(n)
def countZero(n):
if n == 0:
print ("You hit the magic 0 ")
else:
print (n)
countZero(n+2)
countZero()
Aucun commentaire:
Enregistrer un commentaire