How can I change the iteration variable inside a for loop in python?

0 votes
Can you give an example using a nested for loop?
Jun 10 in Python by Waseem
• 2,710 points
16 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Assume you have a list of lists:

my_list = [ [1,2,3] , [4,5,6] , [7,8,9] ]

for lists in my_list:

    for val in lists:

        print(val)

First loop will go through each list inside my_list and the second loop will go through each element in each list

answered Jun 10 by Shubham Bansal

Related Questions In Python

0 votes
1 answer

How can I get the count of a list in Python?

len() >>> mylist=[] >>> print len(mylist) 0 READ MORE

answered Dec 12, 2018 in Python by charlie_brown
• 7,710 points
42 views
0 votes
1 answer

How can I change the data type to string in Python?

You can use str(variablename) This is called conversion ...READ MORE

answered Dec 17, 2018 in Python by Shuvodip
37 views
0 votes
1 answer

How can I lookup hostname using the IP address with a timeout in Python?

Good question. I actually was stuck with ...READ MORE

answered Feb 6 in Python by Nymeria
• 3,500 points
48 views
0 votes
1 answer

How can I find the square of a number in python?

You can use the exponentiation operator or ...READ MORE

answered May 20 in Python by Mohammad
• 1,400 points
14 views
0 votes
0 answers

How can I use the sleep function in a python program?

Can you give a sample code for ...READ MORE

May 23 in Python by Waseem
• 2,710 points

edited May 24 by Omkar 12 views
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
56 views
+4 votes
6 answers

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.