Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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.
Advertisements