I'm a french newbie in Python and I would like to code a program which warns us when the time (string "Day, Hours, Minutes, Seconds") is wrong (for example, 83 seconds). I did this program:
t=input("Put day,hours,minutes,seconds: ")
t="j,h,m,s"
if int(t[6])<=0 or int(t[6])>=59:
print("Seconds wrong")
if int(t[4])<=0 or int(t[4])>=59:
print("Minutes wrong")
if int(t[2])<=0 or int(t[2])>=24:
print("Hours wrong")
if int(t[0])<=0 or int(t[0])>=31:
print("days wrong")
else:
print("OK")
But I've this error:
if t[6]<=0 or t[6]>=59:
TypeError: unorderable types: str() <= int()
So I put "int" everywhere (like "int(t[X])<=0")
but then I've this error:
if int(t[6])<=0 or int(t[6])>=59:
ValueError: invalid literal for int() with base 10: 's'
tfrom user input, then rebindtto a new string, with no integers in it. What do you expect to happen instead? What user input would be given?tas"j,h,m,s"0and59are valid seconds and minutes. You likely want something more liket[6] < 0 or t[6] >= 60. Same with the other time units.