Python Forum

Full Version: help for beginer
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I made this program, but it doesn't work like I want.:
a = int(0)
for a in range (11,21):
    r = '({},{},{})'.format(a, a ** 2, a ** 3)
print(r)
I'd like to have squares and cubes numbers from 11 to 20. However, it shows only for number 20. Where is my mistake please?
If you indent your final line, it will do what you want. You can also remove the first line, it doesn't do anything useful.
thank you
that works fine.
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC v.1500 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> a = int(0)
>>> for a in range (11,21):
r = '({},{},{})'.format(a, a ** 2, a ** 3)
print®


(11,121,1331)
(12,144,1728)
(13,169,2197)
(14,196,2744)
(15,225,3375)
(16,256,4096)
(17,289,4913)
(18,324,5832)
(19,361,6859)
(20,400,8000)
>>>