+ 1

Scoring a three-of-a-kind

This is continuing my first little Python project. I've got it to score ones and fives correctly. I've tried several versions of syntax trying to get it to recognize a three-of-a-kind. No errors, strangely, but tends to score each instance instead of the set of three. def keep_score(throw_choice): score = 0 for i in (throw_choice): if i == [1]*3: score += 1000 if i == [2]*3: score += 200 https://code.sololearn.com/cGXTStr95INy/?ref=app

10th Dec 2017, 2:55 AM
Paul
Paul - avatar
3 Answers
+ 1
the statement 'for i in (throw_choice):' enumerate only 1 item at a time, which is an integer. so it will never match [1]*3, which is [1, 1, 1] Do not use the for loop and try below: if [1]*3 in throw_choice: score += 1000 if [2]*3 in throw_choice: score += 200 ...
10th Dec 2017, 10:29 PM
Lindsay Linjie Chen
Lindsay Linjie Chen - avatar
+ 1
Thank you Lindsay! Super helpful! I finally got my account authenticated so I can give you a well deserved upvote! 😃
14th Dec 2017, 7:23 AM
Paul
Paul - avatar
+ 1
lol.Thank you Paul!
15th Dec 2017, 11:15 PM
Lindsay Linjie Chen
Lindsay Linjie Chen - avatar