I need help with Military time | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I need help with Military time

My code for Military time isn't working for test cases 3,4 and 5. Can I guys help me with where I'm going wrong? https://code.sololearn.com/cc6XLK0B1625/?ref=app

13th Jul 2021, 12:41 AM
Francis Omane Asirifi
Francis Omane Asirifi - avatar
1 Answer
0
Hi. A long time ago i found this code: x=input() lst0=list(x) lst=[] for j in range(0,len(lst0)): if lst0[j].isdigit and lst0[j]!=':' and lst0[j]!=' ' and lst0[j]!="P" and lst0[j]!="A" and lst0[j]!="M": lst+=int(lst0[j]), elif lst0[j]==":" and lst0[j]!=' ': lst+=lst0[j], elif lst0[j]==' ': lst+=lst0[j], elif lst0[j]=="P": lst+=lst0[j], elif lst0[j]=="A": lst+=lst0[j], elif lst0[j]=="M": lst+=lst0[j], if lst[1]!=':' and "P" in lst: if lst[0]==1 and lst[1]<=1 and "P" in lst: lst[0]+=1 lst[1]+=2 lst[5]="" lst[6]="" lst[7]="" elif lst[0]==1 and lst[1]==2 and "P" in lst: lst[5]="" lst[6]="" lst[7]="" elif lst[0]==1 and lst[1]==2 and "P" in lst: lst[5]="" lst[6]="" lst[7]="" elif lst[1]==':' and "P" in lst: if lst[0]<=9 and "P" in lst: lst[0]+=12 lst[4]="" lst[5]=""
25th Sep 2021, 2:25 AM
Anurag Saikia