python - if statement not reading characters in string -
i working on program determine if license plate in correct order using python 3.4 (i beginning programming, , doing self assigned home work).
the license plate should in order of 3 letters, , 3 numbers correct order.
this code:
#get data user plate = input('enter lisence plate number: ') #determine if style old or new if len(plate) == 6 , plate[0] >= "a" , plate[0] <= "z"\ , plate[1] >= "a" , plate[1] <= "z"\ , plate[2] >= "a" , plate[2] <= "z"\ , plate[3] >= "0" , plate[1] <= "9"\ , plate[4] >= "0" , plate[4] <= "9"\ , plate[5] >= "0" , plate[5] <= "9": verd = 'works' else: verd = 'not work' #print results print(verd)
when enter license plate abc123, telling me doesn't work.
i have been trying everything, , can not figure out why isn't working.
any appreciated.
by way, error in method in third condition -
and plate[3] >= "0" , plate[1] <= "9" <-------- notice using `plate[1]` instead of [3]
change -
and plate[3] >= "0" , plate[3] <= "9"
Comments
Post a Comment