+ 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])
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])
0
the hour number must start with 0 if it's a digit, they didn't say it but they take it in account.
0
so maybe you should add in the else statement 'print("0"+y[0])'
0
Nothing works still same result
0
use print(('0' if len(y[0].split(':')[0])==1 else '') +y[0]) instead.
0
Nope brother still didn't work
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])
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
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.
0
It was giving me error so I tried just different logic. it was bit lengthy
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
0
thanks Kishan Sudani !
0
Can you tell me what is the output
0
Try to convert the content in the first print statement before you concatenate them
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.😅
- 1
Может кто-нибудь помочь с задачей?
"3. Программа получает на вход последовательность из N целых неотрицательных чисел. Найти количество всех цифр в последовательности чисел.
Ввод данных:
N = 5
23 475 12 1 683"
Нужно решить на Питоне и с использованием цикла while. Понятие того, что можно сделать, есть, но в голову не приходит, как это написать. Буду благодарить вас за помощь столько, сколько хотите, но помощь сильно нужна. Спасибо заранее!