+ 2

Can you give me what is other cases result?

https://www.sololearn.com/coach/70?ref=app Don't know what's wrong because other test case are hidden.. Sorry but I just need other case result.. I don't want to know what's wrong with my code 😅 Code is in python x = input() if "PM" in x: dict = {'1':'13', '2':'14', '3':'15', '4':'16', '5':'17', '6':'18', '7':'19', '8':'20', '9':'21', '10':'22', '11':'23', '12':'00'} y = x.split(":") z = dict[y[0]] n = y[1].split(" ") print(z+":"+n[0]) else: y = x.split(" ") print(y[0])

26th Mar 2020, 4:32 PM
Kishan Sudani
Kishan Sudani - avatar
16 Réponses
+ 2
x = input() if "PM" in x: dict = {'1':'13', '2':'14', '3':'15', '4':'16', '5':'17', '6':'18', '7':'19', '8':'20', '9':'21', '10':'22', '11':'23', '12':'00'} y = x.split(":") z = dict[y[0]] n = y[1].split(" ") print(z+":"+n[0]) else: y = x.split(" ") print(('0' if len(y[0].split(':')[0])==1 else '') +y[0])
26th Mar 2020, 5:26 PM
John Robotane
John Robotane - avatar
0
the hour number must start with 0 if it's a digit, they didn't say it but they take it in account.
26th Mar 2020, 4:46 PM
John Robotane
John Robotane - avatar
0
so maybe you should add in the else statement 'print("0"+y[0])'
26th Mar 2020, 4:48 PM
John Robotane
John Robotane - avatar
0
Nothing works still same result
26th Mar 2020, 4:53 PM
Kishan Sudani
Kishan Sudani - avatar
0
use print(('0' if len(y[0].split(':')[0])==1 else '') +y[0]) instead.
26th Mar 2020, 5:05 PM
John Robotane
John Robotane - avatar
0
Nope brother still didn't work
26th Mar 2020, 5:10 PM
Kishan Sudani
Kishan Sudani - avatar
0
as I said it, the hour should start with a 0 if it is a digit, so we check if the length of the hour string ==1,in such a case, it is a digit then we print 0 else we print nothing ''. the instructions can be 'decompressed' time_ = y[0].split(":") h_zero = '0' if len(time_[0]) ==1 else '' print(h_zero+y[0])
26th Mar 2020, 5:17 PM
John Robotane
John Robotane - avatar
0
I tried it bro.. I know if it's between 0 to 9 we need to add 0 first I tried but It didn't work
26th Mar 2020, 5:18 PM
Kishan Sudani
Kishan Sudani - avatar
0
did you try the instruction I gave you? print(('0' if len(y[0].split(':')[0])==1 else '') +y[0]) I tried it and it worked.
26th Mar 2020, 5:23 PM
John Robotane
John Robotane - avatar
0
It was giving me error so I tried just different logic. it was bit lengthy
26th Mar 2020, 5:25 PM
Kishan Sudani
Kishan Sudani - avatar
0
Wtf man 🙏 thank you it worked but I tried it but don't know what I done wrong seriously man thank you I appreciate that
26th Mar 2020, 5:29 PM
Kishan Sudani
Kishan Sudani - avatar
0
thanks Kishan Sudani !
26th Mar 2020, 5:32 PM
John Robotane
John Robotane - avatar
0
Can you tell me what is the output
27th Mar 2020, 11:26 AM
Kishan Sudani
Kishan Sudani - avatar
0
Try to convert the content in the first print statement before you concatenate them
28th Mar 2020, 4:05 AM
Phillip Santei
Phillip Santei - avatar
0
If the code converts 1 PM to 13, 2 PM to 14,.....12 PM to 00 ,but isn't that wrong. 11:59 PM to 23:59 that's right in the code ,but if 12:30 PM is given it needs to be 12:30 itself and not 00:30 as per the code THE HIDDEN TEST CASE WOULD BE A 12:XX PM,I think Think '12':'00' in the code is the problem I'm new to python and more over the code stuff.So sorry if it's of no use.😅
28th Mar 2020, 4:23 PM
Max
Max - avatar
- 1
Может кто-нибудь помочь с задачей? "3. Программа получает на вход последовательность из N целых неотрицательных чисел. Найти количество всех цифр в последовательности чисел. Ввод данных: N = 5 23 475 12 1 683" Нужно решить на Питоне и с использованием цикла while. Понятие того, что можно сделать, есть, но в голову не приходит, как это написать. Буду благодарить вас за помощь столько, сколько хотите, но помощь сильно нужна. Спасибо заранее!
27th Mar 2020, 11:05 AM
Олень
Олень - avatar