Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
def obtain_type_player(self):
    '''
    This method will be used by the sub-classes PlayerHuman and PlayerComputer.

    Returns:
        Le type de player, 'Computer' or 'Human'
    '''



    return 'Human' or 'Computer'



I was wondering if this would return the rght thing for me or if i had to add some code.

What I have tried:

This is using Python OOP and since its linked to a lot of other method, im confused but im just here to make sure that this is the way to return it because its hard for me to test in my code in a way.
Posted
Updated 22-Nov-18 4:49am

1 solution

How can it decide which value to return? You need to add a decision statement (if) to select the correct answer. Something like:
Python
def obtain_type_player(self):
    type = "Computer" # the default answer
    if some_other_information is true:
        type = "Human"
    return type
 
Share this answer
 
Comments
CPallini 22-Nov-18 11:33am    
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900