Building a simple calculator for my first Python project and encountered a question shown in the comments below:
special_keys = ["`", "~", "!", "@", " ", "#", "$"]
while True:
num1 = input("Enter First Number: ")
if num1.isalpha():
print("Invalid, Try Again.")
continue
# elif num1 contains an element or part of an
# element in special_keys do the following:
# print("Invalid, Try Again.")
# continue
else:
num1 = float(num1)
break
Aucun commentaire:
Enregistrer un commentaire