+ 1
Python3 for loop nested
for q in range(10): q ** 2 print(q) for l in q: p = l ** 2 print(p) I’m having trouble to fix this code in order to have every number in the range powered two times. I know there are other different methods to accomplish this task, but i want to do it in this way, if is possible. Pycharm is rising this error: TypeError: 'int' object is not iterable Please help me!
4 Antworten
0
for i in range(9):
for j in range(2):
i=i**2
print(str(i))
Anyway I found it
+ 10
This is what *I suppose* you want.
for q in range(10):
q = q ** 2
print(str(q) + ':', end='')
for l in range(q):
p = l ** 2
print(str(p)+' ', end='')
print('')
+ 1
I i basically want this output:
0
1
16
81
256
625
1296
2401
4096
6561
I want to power the power ((3**2)**2)
0
for q in range(10):
print(q**4)