ans = raw_input("Please set the starting juvenile population (or type same to leave it unchanged):")
cont, num = setGen0Check(ans, 0)
if cont == 1:
if num == 1:
juvenilePop = round(float(ans), 3)
else:
invalidInput()
y = setGen0(x, y, z)
def setGen0Check(ans, bounds):
cont = 1
cont2 = 1
num = (numOrStrCheck(46, 57, ans))
if ans.lower() != "same" and num == 0:
invalidInput()
count = 0
elif len(ans) == 0:
invalidInput()
cont = 0
elif num == 1:
if float(ans) < 0:
invalidInput()
cont = 0
if bounds == 1:
cont2 = setGen0bounds(0, 1, ans)
if bounds == 2:
cont2 = setGen0bounds(15, 25, ans)
if cont == 1 and cont2 == 1:
return 1
else:
return 0
return num
def numOrStrCheck(lowerBnd, higherBnd, ans):
for i in ans:
b = ord(i)
if b > higherBnd or b < lowerBnd:
return 0
return 1
Objekttyp „int“ Fehler wiederholen Immer, wenn ich ihm einen Eingang geben erhalte ich die Fehlermeldung:kann nicht ohne Iterieren durch eine ganze Zahl
TypeError: 'int' object is not iterable
mit einer Linie referance:
cont, num = setGen0Check(ans, 0)
Es funktionierte, bis ich mich entschloss, String-Eingaben zuzulassen (meine Passage, ob es eine Zahl ist oder nicht, in die gleiche Funktion wie die Eingabe).
Vielen Dank für die Hilfe, ich werde das in Zukunft berücksichtigen. – UncarbonatedMilk