Jul-29-2019, 04:37 PM
(Jul-29-2019, 01:21 PM)fishhook Wrote: 2. Your code works wellYOUR code works well because you replaced the x = input("Insert number: ") with x = 100.
a = [100, 100, 50, 20, 100, 30] x = 100 c = 0 for i in range(len(a)): if x == a[i]: c = c + 1 print(c) >>> 3
HIS code doesn´t work because the input function returns a string and not an integer value.
So the code must be edited into x = int(input("Insert number: "))