- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to use multiple for and while loops together in Python?
You can create nested loops in python fairly easily. You can even nest a for loop inside a while loop or the other way around. For example,
for i in range(5): j = i while j != 0: print(j, end=', ') j -= 1 print("")
This will give the output
1, 2, 1, 3, 2, 1, 4, 3, 2, 1,
You can take this nesting to as many levels as you like.
- For and While loops in Arduino
- How to use nested loops in Python?
- How to use else statement with Loops in Python?
- How to use single statement suite with Loops in Python?
- Can we use NOT and AND together in MongoDB?
- How to iterate over dictionaries using 'for' loops in Python?
- How to zip a Python Dictionary and List together?
- Can I use MySQL COUNT() and DISTINCT together?
- Can we use LIKE and OR together in MySql?
- What is basic syntax of Python for Loops?
- How to sort a data frame in R by multiple columns together?
- How to use together the date and time format characters in MySQL DATE_FORMAT() function?
- How to make use of both Take and Skip operator together in LINQ C#?