0
Identifying variable type and using raise
Hi everyone! Can anyone please tell me why I'm getting a syntax error on raise? x = str(input("Name please: ")) elif x != str: raise else: print("Hello " + str(x)) I'm trying to have it verify that x is a string, and if it's not then raise an exception. Thanks in advance!
2 odpowiedzi
0
if type(x) != str:
by the way, input will always be string, so if is redundant.
0
Choe oh yes I'd forgotten that. Thank you!