Hi,
I am doing an exercise but somehow my code doesn't work. It should ask for a colorname and when the user types red, orange, yellow, green or blue it should state that the color is in the list.
I get this error message when running the program:
Thanks in advance for the help!
I have another problem in this code: unexpected indent error before
What is the error?
Any input is very much appreciated!
I am doing an exercise but somehow my code doesn't work. It should ask for a colorname and when the user types red, orange, yellow, green or blue it should state that the color is in the list.
I get this error message when running the program:
Error: while str.upper(ColorSelect) != "STOP":
NameError: name 'ColorSelect' is not defined
What am i doing wrong?Thanks in advance for the help!
Colors = ["Rood", "Oranje", "Geel", "Groen", "Blauw"] Colorselect = "" while str.upper(ColorSelect) != "STOP": ColorSelect = input("Typ een kleurnaam: ") if (Colors.count(ColorSelect) >= 1): print("De kleur staat in een lijst!") elif (str.upper(ColorSelect) !="STOP"): print("De kleur staat niet in een lijst.")
I have another problem in this code: unexpected indent error before
" aantal: ", ThisItem[1])
What is the error?
Any input is very much appreciated!
from collections import Counter MyList = [1, 2, 3, 4, 1, 2, 3, 1, 2, 1, 5] ListCount = Counter(MyList) print(ListCount) for thisItem in ListCount.items(): print("Item: ", ThisItem[1]) " aantal: ", ThisItem[1]) print("De waarde 1 verschijnt {0} keer." .format(ListCount.get(1)))