'One of my assignment question - Just looking to keep it simple

The program will take one argument, corresponding to one of the relations' keys. The program will print out the statement:

John, I am your x

Where x = the relationship.

For example, if the argument is "Lisa", it should print "John, I am your sister"

If the key is "Smith" you should instead print "No, I am your father"

Here is my code:

def Relation(name):

    name = str(sys.argv[1])

    relations = {'Smith':'father', 'Lisa':'sister', 'Han':'brother in law',\
     'R2D2':'droid', 'Rey':'Padawan', 'Tatooine':'homeworld'}

    if name == 'Darth Vader':
        print("No, I am your father")

    else:
        print("John, i am your %s"%(relations[key]))

Relation()

I'm getting an error in this code: missing 1 required positional argument - what am I missing here?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source