0
What is the error? Python language
10 Answers
+ 3
First, Please post your CODE here:
Second, You are trying to do the code for just the first 2 test cases that is wrong.
The next 3 test cases are always hidden.
Many People do this 'mistake'.
Don't worry it's fine.
I have also done in python like this:
t = input().split()
hm = t[0].split(":")
h = int(hm[0]) + 12 if t[1] == "PM" else hm[0]
print(f"{h:0>2}:{hm[1]}")
It is not too long.
Hope it helpsđ
+ 3
This is my one
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]=""
lst[6]=""
elif lst
+ 2
If u will share coach Question link it will not show other users paste your code here or in codebit and sharr link
+ 2
Thank u so much Ezra Bridger 2207 I will try this now
+ 1
Lots and lots of thanks Ezra Bridger 2207 I tried this now it came correct at the same time I have understood the concept also
+ 1
Welcomeđ
Keep it up and solve more solutions.
It will keep up your spirit and you would test how much you have learned.
0
Oh OK â¨ď¸â¨ď¸
0
def convert24(str1):
if str1[-2:]=="AM" and str1[:2]=="12":
return "00"+str1[2:-4]
elif str1 [-2:]=="AM":
return str1 [:-2]
elif str1[-2:]=="PM" and str1 [:2]=="12":
return str1 [:-2]
else:
return str(int(str1 [:2])+12)+str1[2:6]
print(convert24 (input()))
0
This is my code đkindly help me to solve
0
Thank u K.S.S. KARUNARATHNE