0

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);
3
Contributors
4
Replies
5
Views
4 Years
Discussion Span
Last Post by Vusumuzi
0

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.

0

@ 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.

0

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
0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.