+ 1
Here the name takes any data type. How can I make sure it only accepts a string?
5 odpowiedzi
+ 8
I don't think u can prevent input() from taking a number. What u can do is to make ur code raise an exception when someone enters a number, say:
string = input("Do not enter a number:")
try:
string = int(string)
except ValueError:
print("Good, you didn't enter a number")
else:
print("Why did u enter a number?")
OR
string = input("Do not enter a number:")
if string.isalpha():
print("Good, you didn't enter a number")
else:
print("Why did u enter a number?")
+ 7
str(input()) instead of input()
+ 4
str.isalpha()
+ 2
ok. well its converting all the digits to string. hence not much difference