Basically, I am new to programming and I sign up for a python course. I receive an exercise asking as follow:
Build a function that returns, given an arbitrary birth year, the Chinese zodiac sign corresponding to that calendar year. You start from a dictionary of Chinese zodiac signs from 2001-2012 (covering the whole 12-sign cycle)
So my idea is to create a dictionary,
d={2001:'Snake',2002:'Horse',2003:'Goat',2004:'Monkey',2005:'Rooster',2006:'Dog',
2007:'Pig',2008:'Rat',2009:'Ox',2010:'Tiger',2011:'Rabbit',2012:'Dragon'}
And I begin with the for statement
def year(x):
for x in d.keys:
if x=d.keys:
print d.value
else:
x..
I basically have no idea how to approach the next step. Can someone please me some direction?
question from:https://stackoverflow.com/questions/65838141/for-statement-from-dictionary-python