What i am trying to do do is this.
1.User Inputs a number (for example a SSN or any Identification number) 2.If the user is not 14 digits, return to the input and try again 3.If Input is 14 digits, continue in program. 4.Check if SSN starts with 1 or 2 (in my scenario all male ID start with 1 and all female ID start with 2 5. If 1 print male if 2 print female.
My last code is:
ssn=str(input("SSN: "))
x=len(ssn)
while x != 14:
print("Wrong digits")
break
else:
print("Thank you")
y=str(ssn[0])
if y == 1:
print("Male")
else:
print("ok")*
In execution i get:
SSN: 12345 Wrong digits ok
The problem is that this does not break if i input 12 digits. It does say wrong digits but continues to in the execution. Second problem is that it prints ok even though i added 1234 which starts with 1 and it should be male.
Any ideas on this please?