Day 009 - Project 9 : Generation Generator

If you have any questions, comments or issues with this project please post them here!

1 Like

Felt like I was at Hogwarts with all the casting I did today :european_castle::mage: !

Day 9 of #Replit100DaysOfCode #100DaysOfCode.


I researched how to do multiple conditional statements in one if statement.

I used this guide: Check multiple conditions in if statement – Python - GeeksForGeeks

So, I ended up with multiple parentheses around each set of multiple conditional statements:

#Day 9 of Replit's 100 Days of Code
#Working with Numbers
year=int(input("What year were you born? "))
if ((year >= 1946) and (year <= 1964)): print("You are a Baby Boomer!")
elif ((year >= 1965) and (year <= 1980)): print("You are Generation X!")
elif ((year >= 1981) and (year <= 1996)): print("You are a Millennial!")
elif ((year >= 1997) and (year <= 2012)): print("You are Generation Z!")
elif year >= 2013: print("You are Generation Alpha!")
else: print("Enjoy your retirement!")

I saw in the code reveal that those parentheses are not needed. I would guess that it is preferred to leave them out. Could you please tell me if there is good reason to include the parentheses, apart from personal preference?

Thank you!

[100 Days Of Code] Day 9

I had some more fun with it this time


1 Like

For readability you can keep them, but still the outer most can go anyhow