0
What's wrong with this code?
I know I need to feed an input for condition that's not entirely why this code is going wrong. The output conveniently goes right with else work work. I'm still learning so tried datetime.today().day to define "today" but that didn't seem to work either. Why? https://code.sololearn.com/cHUOM7dyK6OP/?ref=app
6 Respostas
+ 4
Akhil Padmanabhan
you should give a number to if statement not a string !
because: 22 != '22'
so... use:
if today == 22:
instead of:
if today == 22:
full code working:
from datetime import datetime
today = datetime.today().day
if today == 22:
print("Party!")
elif today == '24':
if condition == ("headache"):
print("I should have a cup of tea")
else:
print ("Call Debbie")
else:
print ("work work work work work work.. I love you Riri")
print (today )
#what's wrong with code? Please comment.
+ 4
Akhil Padmanabhan
first try this code...
from datetime import datetime
today = datetime.today().day
if today == 22:
print("Party!")
elif today == 24:
if condition == ("headache"):
print("I should have a cup of tea")
else:
print ("Call Debbie")
else:
print ("work work work work work work.. I love you Riri")
#what's wrong with code? Please comment.
+ 4
Akhil Padmanabhan
you can read a good tutorial for taking input here:
https://www.geeksforgeeks.org/taking-input-in-JUMP_LINK__&&__python__&&__JUMP_LINK/
or instead, read sololearn tutorial:
https://www.sololearn.com/learn/Python/2426/
I hope I was helpful
+ 4
Akhil Padmanabhan you are welcome! :)
+ 1
Alessio
Yo man that's working totally..
Now I want to assign an input for condition how do i do that?
from datetime import datetime
today = datetime.today().day
condition = input("Are you having a headache?" )
if today == 25:
print("Party!")
elif today == 22:
if condition == ("Yes"):
print("I should have a cup of tea")
else:
print ("Call Debbie")
else:
print ("work work work work work work.. I love you Riri")
+ 1
Alessio
Hell yea.. Thank you so much!!