Iterate through an integer, is that possible? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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?.

6th Apr 2019, 10:08 PM
Nebula_x1 🛸
Nebula_x1 🛸 - avatar
1 Answer
+ 2
N = list(str(N)) if n == "4":
6th Apr 2019, 11:30 PM
Diego
Diego - avatar