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!

18th May 2019, 3:07 AM
Derrick
Derrick - avatar
2 ответов
0
if type(x) != str: by the way, input will always be string, so if is redundant.
19th May 2019, 1:22 PM
Choe
Choe - avatar
0
Choe oh yes I'd forgotten that. Thank you!
19th May 2019, 1:55 PM
Derrick
Derrick - avatar