Python Age Input Program To determine if the input number is an input number.

Asked 2 years ago, Updated 2 years ago, 22 views

while True:

    a=input ('Enter your age:')
    if type(a)==str:
        print ('Please enter an age number')
    else:
        print('OK')
        break

I'm a beginner at Python. I've done this much, but I can't do it anymore. Haha.

If you receive your age as a non-integer string, you must create a program that repeats until you enter your age.

Thank you

python

2022-09-22 18:21

1 Answers

if type(a)==str: 

Instead, write it like this

if type(a)=='<class \'str\'>':


2022-09-22 18:21

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.