Answer the question
In order to leave comments, you need to log in
How to check if all values are positive and all input values inside a for loop?
Hello everyone, I have a for loop to populate list data.
Inside the loop, you need to check whether these are numbers and whether they are positive, how can I do it?
val = 3
for i in range(val):
x.append(int(input("Input BBU " + str(i+1) + ": ")))
print(x)
val = 3
for i in range(val):
ab = x.append(input("Input BBU " + str(i+1) + ": "))
while True:
print(ab)
try:
val = int(ab[i])
if val <=0:
print("not")
continue
break;
except ValueError:
print("notnot")
print(x)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question