So I’m currently learning Python and I came across a problem with a None value. I’am asking myself what does it mean in the context of the short program and is there any way to visualize it?
list = eval(input("Enter a list with positive numbers: "))
n = len(list)
i = 0
*previous = None*
erg = []
while i < n:
current = list[i]
i += 1
*if current == previous:*
continue
if current <= 0:
print("Negative number found!")
break
erg.append(current)
previous = current
print(erg)
The lines I don’t understand are in Italic. So is the line current == previous just checking if there is a value at all or not and positive values get left out in the while-loop?
New contributor
Jujuthecoder is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.