Answer the question
In order to leave comments, you need to log in
A program that asks you to enter anything and after entering it gives 'Ok', but if you just press Enter without entering anything, the program will stop. How to do?
Can't get the desired result. Enter is recognized as a letter.
z = input ("Введите что-нибудь: ")
#число
if type (z) == int:
print ("Ok")
#дробное число
elif type (z) == float:
print ("Ok")
#текст
elif type (z) == str:
print ("Ok")
#Enter
elif
Answer the question
In order to leave comments, you need to log in
To test z for type, you must first cast z to the correct type. And you will always have a string in the z variable (until you manually convert it to another type)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question