+ 1
Iterate through an integer, is that possible?
Take two integers (A, B) as input, compute N = A + B. Eg. 55 + 69 = 124 Make a list of figures in N. Eg. ['1', '2', '4'] Check for a number n in N. Something like this: A=int(input(":")) B=int(input(":")) N = A + B N = list(N) for n in N: if n == 4: print("There's a 4") else: print("There's no 4") #I get an 'int object is not itrable' error OR: N_list = [] A=int(input(":")) B=int(input(":")) N = A + B N_list.append(N) for n in N_list: if n == 4: print("There's a 4") else: print("There's no 4") #this doesn't work either, i get a single element in #the list How do i do that?.
1 Antwort
+ 2
N = list(str(N))
if n == "4":