Python Forum
Need help on this nested loop task
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help on this nested loop task
#3
Lets start from the beginning.

You have given two things.

1. Array with four items in it.

2. A integer variables.

The homework problem said print every element in array x 6 times. Then print something else.

First build a for else loop that refer to line of sanity variable.
#For loop with else while

Then build a separate loop that prints all items in array.

If you can build those loops, then try to nest one for loop with in another.

When I saw this problem, I didn’t know this. But I know python have some loop functions. So visited here to look up.
https://www.w3schools.com/python/python_for_loops.asp

Learn to break down one big problem to smaller chucks and then solve the parts.

The range() Function
This is how to use integer variable in for loop.

Else in For Loop
This is how you break out of loop.

Nested Loops
This is how you nest one for loop with another.

Build it in order separately. After that combine.
Reply


Messages In This Thread
Need help on this nested loop task - by PP9044 - Apr-07-2021, 02:03 AM
RE: Need help on this nested loop task - by MH90000 - Apr-16-2021, 08:12 AM
RE: Need help on this nested loop task - by MH90000 - Apr-16-2021, 08:23 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Nested if stmts in for loop johneven 2 5,928 Oct-19-2019, 04:05 AM
Last Post: xeedon
  Nested for loop issue always using index 0 searching1 2 2,634 Dec-30-2018, 09:17 AM
Last Post: searching1
  nested while loop flow help Ponamis 4 3,023 Nov-02-2018, 11:22 PM
Last Post: Ponamis
  Nested loop Tryhard20 3 5,778 Sep-05-2018, 04:57 AM
Last Post: volcano63
  Nested Loop multiplication table SushiRolz 3 10,285 Feb-28-2018, 04:34 AM
Last Post: Larz60+
  Nested Loop to Generate Triangle Babbare 12 11,856 May-29-2017, 05:00 AM
Last Post: buran

Forum Jump:

User Panel Messages

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