lundi 1 juin 2020

Type of data in an F statement [closed]

I am a total newbie in Python. Could you help out with the following code?

ID_number = int(input("Write your ID_number: "))    
if str(ID_number[9]) %2 ==1:
 print("male")
else:
 print("female")

I suspect the problem may lie in this line, where I am not sure of correct type of data: string or integer

if str(ID_number[9]) %2 ==1:

I get an error "'int' object is not subscriptable". I searched for a possible problem on this website and many others, but still cannot find my error.

Thank you

Aucun commentaire:

Enregistrer un commentaire