Python Forum
If the argument is not int then make it int!
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If the argument is not int then make it int!
#1
Lightbulb 
Hi !
I have to write a function named Countdown:
def countdown(n):
    while n > 0:
        print(n)
        n = n - 1
    print('Blastoff!')
Now if I enter a non-integer value and I want Python to change it to int value how should I get Python to do that?

I treid with this:
def countdown(n):
    if n not int(n):
       n=int(t) 
    while n > 0:
        print(n)
        n = n - 1
    print('Blastoff!')
What is wrong with this code?
Reply


Messages In This Thread
If the argument is not int then make it int! - by pooyan89 - Dec-11-2020, 02:25 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  creating functions - make optional argument a reversal anstuteville 2 2,661 Aug-31-2018, 02:36 PM
Last Post: anstuteville

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020