+ 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
6 odpowiedzi
+ 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)
+ 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 :)
+ 3
G B Thanks!! It worked!! 😋😊
+ 1
x= 3
if x==3:
do 1
else:
do 2
else block executes if only if condition is false
0
G B Tried Out The Indentation Adjustment But Didn't Work😋
0
Avalon Nope Bro, I Interchanged the if and else statement,still no result