+ 2

Why is the else part not executing?

First case is working but it's not going into the second case https://code.sololearn.com/c68ao2YLY2l7/?ref=app

14th Oct 2020, 5:07 AM
𝖀𝖙𝖐𝖆𝖗𝖘𝖍 𝕸𝖎𝖘𝖍𝖗𝖆
𝖀𝖙𝖐𝖆𝖗𝖘𝖍 𝕸𝖎𝖘𝖍𝖗𝖆 - avatar
6 ответов
+ 2
Sorry, you still should convert th to str ... t = input() t2=t.replace(" ",":") print(t2) t_h=t2.split(":") print(t_h) t_tf="" if t_h[2]=='AM': t_tf = t_h[0]+":"+t_h[1] print(t_tf) else: th=int(t_h[0])+12 if(th>24): th=th-24 t_tf= str(th) + ":" + t_h[1] print(t_tf)
14th Oct 2020, 6:37 AM
G B
G B - avatar
+ 3
The else Part is executing... It fails on the next if condition (th>24).. Just unindent lines 14 and 15 and It will work... I'm Not Sure if there needs to be some further adjustment around 00:00 and 12:00. There is just something ringing in my head... But you'll find this out :)
14th Oct 2020, 6:25 AM
G B
G B - avatar
+ 3
G B Thanks!! It worked!! 😋😊
14th Oct 2020, 6:40 AM
𝖀𝖙𝖐𝖆𝖗𝖘𝖍 𝕸𝖎𝖘𝖍𝖗𝖆
𝖀𝖙𝖐𝖆𝖗𝖘𝖍 𝕸𝖎𝖘𝖍𝖗𝖆 - avatar
+ 1
x= 3 if x==3: do 1 else: do 2 else block executes if only if condition is false
14th Oct 2020, 6:30 AM
Shadoff
Shadoff - avatar
0
G B Tried Out The Indentation Adjustment But Didn't Work😋
14th Oct 2020, 6:31 AM
𝖀𝖙𝖐𝖆𝖗𝖘𝖍 𝕸𝖎𝖘𝖍𝖗𝖆
𝖀𝖙𝖐𝖆𝖗𝖘𝖍 𝕸𝖎𝖘𝖍𝖗𝖆 - avatar
0
Avalon Nope Bro, I Interchanged the if and else statement,still no result
14th Oct 2020, 6:38 AM
𝖀𝖙𝖐𝖆𝖗𝖘𝖍 𝕸𝖎𝖘𝖍𝖗𝖆
𝖀𝖙𝖐𝖆𝖗𝖘𝖍 𝕸𝖎𝖘𝖍𝖗𝖆 - avatar