After entering a number or character in the input value, the corresponding command statement is not possible.

Asked 2 years ago, Updated 2 years ago, 47 views

b=input("input")

if int(b)==int:
    print("Just write letters,")
elif str("b")==str:
    print ("Just write the numbers")

This prevents the print value from running when you write down numbers, and errors occur when you write down characters. What should I do?

input python

2022-09-20 19:22

1 Answers

b=input("input")

if b.isdigit():
    print ("Write only letters")
elif b.isalpha():
    print ("Just write the numbers")
else:
    print ("Mixed String")


2022-09-20 19:22

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.