Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help for beginer
#1
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?
Reply
#2
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.
Reply
#3
thank you
Reply
#4
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)
>>>
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Please help to the beginer polo 4 2,895 Mar-27-2019, 01:22 AM
Last Post: polo
  Python for beginer triluan 2 2,378 Mar-03-2019, 12:40 PM
Last Post: triluan
  Need Help with Start-up (DIY Beginer) Styles4gh 2 2,465 Mar-09-2018, 02:06 AM
Last Post: Larz60+
  beginer oop help noissue 7 6,855 Oct-12-2016, 03:45 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020