The problem is that, I don’t know how to observe the end of the series.
What i mean:
variable = 1
variable = 2
variable = 3
(...)
variable = 14
This "variable" grows to a random number (for example: 14) and then suddenly drops to 0
variable = 0
The biggest problem is that I don’t know at what number the "drop" will occur.
How to detect this kind of behavior? (I want to save the number where it occurred, in this case it is "14") Has anyone ever had a similar problem to solve?
Sample code:
series = 0
i=1
while i==1:
variable = 1 (web scraped data e.g "1")
if variable ==1:
series = series + 1
else:
series = 0
>Solution :
Two ways:
1 – You can create a global variable to store the max value of variable in each iteration
max_value = None
while <condition>:
if variable > max_value: max_value = variable
....
2 – Using List, and get a max of the list. This way you can store all occurrences of the variable
valueList = []
while <condition>:
valueList.append(variable)
....
max_vale=max(valueList) #after the while loop