Thank you so much CoderElijah for suggesting the new method. I will try it.
No, not school assignments. I was just referring to the challenges posted for each day of the course. I am just trying to figure out what the best way to check if the python code I came up with is correct or not.
[100 Days Of Code] Day 8 This is mostly a note for me to keep me motivated for 100 days
Day 8- Day 8 went pretty well I am still enjoying doing this course of 100 days of code and canât wait to get to day 100! I love this because even though Iâm still doing stuff I already know how to enjoy redoing it. Itâs been a lot of fun and I am ready to keep going!
Question:
hi! Iâm currently doing the 100 days of python course and I have to create an affirmation generator. for some reason, when I type in âsabineâ âtuesdayâ âgreatâ the output for monday is coming. with âsabineâ âtuesdayâ âgoodâ the tuesday output is coming. I must have used the or-statement wrong, but I donât know what to change
code snippet
Name = input ("What's your name?")
Day = input ("What day of the week is it?")
Feeling = input ("How are you feeling?")
if Name == "Sabine" or Name == "sabine" and Day == "Monday" or Day == "monday" and Feeling == "good" or Feeling == "Good" or Feeling == "great":
print ("Sabine just starting the week with that positive ernegy, amazing! You'll rock this week for sure!")
elif Name == "Sabine" or Name == "sabine" and Day == "Monday" or Day == "monday" and Feeling == "bad" or Feeling == "tired":
print('''Monday is the hardest day of the week,
but also just it's beginning! Take a moment for yourself,
drink a coffee and remember that you just gotta find the right attitude to rock it!''')
elif Name == "Sabine" or Name == "sabine" and Day == "Tuesday" or Day == "tuesday" and Feeling == "good" or Feeling == "Good" or Feeling == "great":
print ("whoop whoop sabine feeling good and looking awesome!")
Hello! I donât think so, because I donât want that the user has to say he is feeling âgood, Good, greatâ. I just want that it doesnât matter if heâs saying good, Good or great, the answer will occur either way. Thatâs why I used or, just one condition has to be true for the statement to be true.
As I remember, python process âandâ before âorâ, correct me if this isnât true
Try bracketing the statements, such like
To if (Name == "Sabine" or Name == "sabine" )and (Day == "Monday" or Day == "monday") and (Feeling == "good" or Feeling == "Good" or Feeling == "great"):
Name = input ("What's your name?")
Day = input ("What day of the week is it?")
Feeling = input ("How are you feeling?")
if Name == "Sabine" or Name == "sabine":
if Day == "Monday" or Day == "monday":
if Feeling == "good" or Feeling == "Good" or Feeling == "great":
print ("Sabine just starting the week with that positive ernegy, amazing! You'll rock this week for sure!")
elif Feeling == "bad" or Feeling == "tired":
print('''Monday is the hardest day of the week,
but also just it's beginning! Take a moment for yourself,
drink a coffee and remember that you just gotta find the right attitude to rock it!''')
elif Day == "Tuesday" or Day == "tuesday" :
if Feeling == "good" or Feeling == "Good" or Feeling == "great":
print ("whoop whoop sabine feeling good and looking awesome!")
I believe this should work. If it doesnât, please tell me!
In my code, you first check if the name in Sabine.
Then, you check if the day is Monday. If it is, you check if the feeling is good or bad, and a statement is printed based on the feeling.
Returning back to the day check, if itâs Tuesday, check if the feeling is good.
If it is, a happy message is displayed.
Make the code even simpler with case-insensitive input (the norm), and in operators.
Name = input("What's your name?").lower()
Day = input("What day of the week is it?").lower()
Feeling = input("How are you feeling?").lower()
if Name == "sabine":
if Day == "monday":
if Feeling in ("good","great"):
print("Sabine just starting the week with that positive energy, amazing! You'll rock this week for sure!")
elif Feeling in ("bad","tired"):
print('''Monday is the hardest day of the week,
but also just it's beginning! Take a moment for yourself,
drink a coffee and remember that you just gotta find the right attitude to rock it!''')
elif Day == "tuesday":
if Feeling in ("good","great"):
print("whoop whoop sabine feeling good and looking awesome!")
Hi! When I run my code and enter Sunday I do not get the correct print statement instead the print statement for the else statement prints out. Does anyone know what I could be missing? https://replit.com/@StaceyGraham/day-8-100-days