mardi 28 juillet 2020

what does 0 mean? how can it have three items

I have trouble understanding these lines of codes:

return (0, user, computer)
return (-1, user, computer)

My question: what does 0, -1, and 1 mean? How can () have three items inside?

Thanks very very much!I'm a beginner. Much help is needed and appreaciated.

the original code is below: def play(): user = input("What's your choice? 'r' for rock, 'p' for paper, 's' for scissors\n") user = user.lower()

computer = random.choice(['r', 'p', 's'])

if user == computer:
    return (0, user, computer)         #?????????????????

# r > s, s > p, p > r
if is_win(user, computer):
    return (1, user, computer)

return (-1, user, computer)

Aucun commentaire:

Enregistrer un commentaire