+ 1

# Problem with split() method

I need to split input text (12:00 AM). Here is my code: a = str(input().split()) #12:00 for i in a: c = i[0] print(c, end = "") #['12:00', 'AM'] But I want to get this ( ['12:00' ]) please help me and sorry for my bad English.

2nd Apr 2020, 4:40 PM
ΠΠ½Π΄ΡΠ΅ΠΉ ΠΠ΅ΡΠΌΡΠΊΠΎΠ²
+ 5
You could just keep it simple https://code.sololearn.com/cTjMmDD1Ox1d
4th Apr 2020, 3:43 PM
David Ashton
+ 3
#you can get an idea from this code otherwise ask time=input() if time=='12:00' or time=='12:00 AM': print("00:00") else: split=time.split() mist=split[1] itsob=split[0] its8=itsob[0:-3] nevermind=itsob[3::] itsmin2=itsob[3::] itsmin=itsob[2::] another=itsob[0:-3] if mist=="PM": if int(its8)<=9: newval=int(its8)+12 print(str(newval)+":"+str(itsmin)) elif int(its8)>9: newval2=int(another)+12 print(str(newval2)+":"+str(itsmin2)) elif mist=="AM": if int(its8)<=9: print("0"+str(another)+":"+str(itsmin)) elif int(its8)>9: print(str(another)+":"+str(nevermind)) #split0 is 08:45
2nd Apr 2020, 5:31 PM
Tricker
+ 2
a = str(input().split()[0]) for i in a: c = i[0] print(c, end = "") #['12:00', 'AM'] In line 1 i have indexed the list's first part.
2nd Apr 2020, 5:01 PM
Tricker
+ 1
Aaah. I got it. It happened because of "str". Man thank you very much!
2nd Apr 2020, 4:59 PM
ΠΠ½Π΄ΡΠ΅ΠΉ ΠΠ΅ΡΠΌΡΠΊΠΎΠ²
+ 1
Π’Π΅ΠΌ Π±ΠΎΠ»Π΅Π΅ ΠΌΠΎΠΆΠ½ΠΎ ΠΈ ΡΠ°ΠΊ Ρ ΡΠΎΠ±ΠΎΠΉ
2nd Apr 2020, 4:59 PM
ΠΠ½Π΄ΡΠ΅ΠΉ ΠΠ΅ΡΠΌΡΠΊΠΎΠ²
+ 1
Π‘ΠΏΠ°ΡΠΈΠ±ΠΎ Π±ΠΎΠ»ΡΡΠΎΠ΅!
2nd Apr 2020, 5:00 PM
ΠΠ½Π΄ΡΠ΅ΠΉ ΠΠ΅ΡΠΌΡΠΊΠΎΠ²
+ 1
Thank you again!
2nd Apr 2020, 5:30 PM
ΠΠ½Π΄ΡΠ΅ΠΉ ΠΠ΅ΡΠΌΡΠΊΠΎΠ²
+ 1
Hello
3rd Apr 2020, 8:15 PM
Belazerava Viktoria
+ 1
It's supposed to be: a = input().split() #["12:00","AM"] then, print(a[0]) #"12:00"
4th Apr 2020, 6:47 AM
David Emmanuel
+ 1
12Γ12=9 23Γ23=16 34Γ34=?
4th Apr 2020, 1:14 PM
Belazerava Viktoria
0
Another one question, I have the mission: a = input().split() b = a[0] r = a[1] c = b.split(":") d = c[0] f = c[1] if r == "AM": print(d + ":" + f) else: g = str(int(d) + 12) print( g + ":" + f ) #time converter
2nd Apr 2020, 5:22 PM
ΠΠ½Π΄ΡΠ΅ΠΉ ΠΠ΅ΡΠΌΡΠΊΠΎΠ²
0
I hope you'll understand
2nd Apr 2020, 5:22 PM
ΠΠ½Π΄ΡΠ΅ΠΉ ΠΠ΅ΡΠΌΡΠΊΠΎΠ²
0
So, 3 tests out of 5 I passed and I do not know why the rest are wrong
2nd Apr 2020, 5:26 PM
ΠΠ½Π΄ΡΠ΅ΠΉ ΠΠ΅ΡΠΌΡΠΊΠΎΠ²
0
For example I have 1:00 PM and my program needs to convert this to 13:00, my program can do it but tests think differently
2nd Apr 2020, 5:28 PM
ΠΠ½Π΄ΡΠ΅ΠΉ ΠΠ΅ΡΠΌΡΠΊΠΎΠ²
0
Mission called "Military time"
2nd Apr 2020, 5:30 PM
ΠΠ½Π΄ΡΠ΅ΠΉ ΠΠ΅ΡΠΌΡΠΊΠΎΠ²
0
Indeed
2nd Apr 2020, 5:30 PM
ΠΠ½Π΄ΡΠ΅ΠΉ ΠΠ΅ΡΠΌΡΠΊΠΎΠ²
0
Omao
2nd Apr 2020, 5:31 PM
ΠΠ½Π΄ΡΠ΅ΠΉ ΠΠ΅ΡΠΌΡΠΊΠΎΠ²
0
Okey
2nd Apr 2020, 5:31 PM
ΠΠ½Π΄ΡΠ΅ΠΉ ΠΠ΅ΡΠΌΡΠΊΠΎΠ²
0
I'll check it
2nd Apr 2020, 5:32 PM
ΠΠ½Π΄ΡΠ΅ΠΉ ΠΠ΅ΡΠΌΡΠΊΠΎΠ²
0
Thanks
2nd Apr 2020, 5:33 PM
ΠΠ½Π΄ΡΠ΅ΠΉ ΠΠ΅ΡΠΌΡΠΊΠΎΠ²