● Create a program, luke.py, using the following dictionary:
relations = {'Darth Vader':'father', 'Leia':'sister', 'Han':'brother in law', 'R2D2':'droid',
'Rey':'Padawan', 'Tatooine':'homeworld'}
● The program will take one argument, corresponding to one of the relations’ keys. The
program will print out the statement:
Luke, I am your x
Where x = the relationship.
● For example, if the argument is Leia, it should print ‘Luke, I am your sister’
● If the key is ‘Darth Vader’ you should instead print “No, I am your father” (here’s why)
def printRelation(key):
relations = {'Darth Vader':'father', 'Leia':'sister', 'Han':'brother in law', 'R2D2':'droid', 'Rey':'Padawan', 'Tatooine':'homeworld'}
if key == 'Darth Vader':
print("No, I am your father")
else:
print("Luke, i am your %s"%(relations[key]))
Calling method
printRelation('Leia')
printRelation('Darth Vader')
Output
Luke, i am your sister
No, I am your father