Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
nested for loop dilemma
#1
Hey guys, so I have been doing some basic tasks on while loops for loops which I completed with some help here and there and I mostly grasped it without too much headache.
The task I have now is proving a major challenge but I think its because I haven't really worked with it before and its my first nested loops assignment.

So, I need to use a nested for loop and create the following numbers pyramid as described below:
I understand that the rows will be defined with the outer loop and the columns with the inner loop.
And the code starts something like this I believe:

for x in range(1,i+1):
Here is what I need to create:

1
2 4
3 6 9
4 8 12 16
5 10 15 20 25
6 12 18 24 30 36
7 14 21 28 35 42 47
8 16 24 32 40 48 56 64
9 18 27 36 45 54 63 72 81

As yet I am just not getting it, I will really be for ever thankful if someone can give me guidance on this,
I do not want the code written for me, after all, I need to learn from this, I just need some pointers because this is driving me mad. Wall

Thanks in advance
Reply


Messages In This Thread
nested for loop dilemma - by YoungGrassHopper - Sep-11-2019, 04:36 PM
RE: nested for loop dilemma - by ichabod801 - Sep-11-2019, 04:44 PM
RE: nested for loop dilemma - by YoungGrassHopper - Sep-11-2019, 04:51 PM
RE: nested for loop dilemma - by YoungGrassHopper - Sep-11-2019, 05:45 PM
RE: nested for loop dilemma - by perfringo - Sep-11-2019, 05:29 PM
RE: nested for loop dilemma - by YoungGrassHopper - Sep-11-2019, 05:52 PM
RE: nested for loop dilemma - by buran - Sep-11-2019, 05:50 PM
RE: nested for loop dilemma - by YoungGrassHopper - Sep-12-2019, 09:05 AM
RE: nested for loop dilemma - by buran - Sep-11-2019, 05:52 PM
RE: nested for loop dilemma - by jsira2003 - Sep-13-2019, 03:56 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Big O runtime nested for loop and append yarinsh 4 1,396 Dec-31-2022, 11:50 PM
Last Post: stevendaprano
  Nested for loops - help with iterating a variable outside of the main loop dm222 4 1,603 Aug-17-2022, 10:17 PM
Last Post: deanhystad
  How do I add another loop to my nested loop greenpine 11 4,574 Jan-12-2021, 04:41 PM
Last Post: greenpine
  Error on nested loop : Invalid syntax dvazquezgu 3 3,240 Nov-25-2020, 10:04 AM
Last Post: palladium
  dilemma with list comprehension spalisetty06 1 1,933 Aug-14-2020, 09:18 AM
Last Post: buran
  Nested loop indexing Morte 4 3,936 Aug-04-2020, 07:24 AM
Last Post: Morte
  Nested for loop not looping puttingwordstogether 0 1,718 Jun-16-2020, 11:15 PM
Last Post: puttingwordstogether
  Help: for loop with dictionary and nested lists mart79 1 1,869 Apr-12-2020, 02:52 PM
Last Post: TomToad
  Nested Loop for user input Ads 2 3,566 Dec-30-2019, 11:44 AM
Last Post: Ads
  openpyxl nested for loop help rmrten 3 5,699 Oct-16-2019, 03:11 PM
Last Post: stullis

Forum Jump:

User Panel Messages

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