Question

Enter a code that will test if player 'A' for team A or 'B' for team B was entered
Call the procedure display_player( , ) with the relevant variables

Enter the code that request the user to enter the positon

My failes answer is:

def diplay_player(team, position):
    team = print raw_input("Which team is the player: ")
    position = print  raw_input("which position: ")
    if team == "A":
        print "The player is in team A and in position", position;
    else:
        print "The player is in team B and in position", position;
    return;

diplay_player(team, position);

Recommended Answers

first no need to use print when assigning a user input to a variable.
secondfunction arguments are pre-requisit for function. so get those two user input vars out of the function.

Jump to Post

All 4 Replies

first no need to use print when assigning a user input to a variable.
secondfunction arguments are pre-requisit for function. so get those two user input vars out of the function.

@ M.S Dude I tried your suggestion and some how it did not work. do you want to edit the code and test it?

Thanks for your responce mate.

Clean it up a little:

def display_player():
    team = raw_input("Which team is the player (A or B): ")
    position = raw_input("Which position: ")
    return team, position


team, position = display_player()

sf = "Player is on team %s in position %s"
if team in 'AB':
    print sf % (team, position)
else:
    print "Unknown team %s" % team

Thanks mate! How I wish I could borrow your brain for tomorrow's exam lol.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.