0

Why does this loop not move past the 1st segment of the list? I want it to tell me how many times each number is in the list.

Numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 2] numb = 0 num = Numbers[numb] Total = Numbers.count(num) while numb < (len(Numbers)): print("The Number", (num), "Occurs", total, "Times") numb = numb + 1

3rd May 2020, 2:40 PM
WILLIAM QUINN
WILLIAM QUINN - avatar
3 Réponses
+ 1
You are incrementing numb inside while loop ,so numb will always be 0
3rd May 2020, 2:43 PM
Abhay
Abhay - avatar
0
Can you advise where this should be? Thanks
3rd May 2020, 2:55 PM
WILLIAM QUINN
WILLIAM QUINN - avatar
0
Try keeping num and Total Inside while loop ,maybe that will work
3rd May 2020, 2:59 PM
Abhay
Abhay - avatar