+ 4

What is the difference between for and while in python in performance?!

5th Dec 2020, 9:30 AM
Ali.Asghar.Esmailian
Ali.Asghar.Esmailian - avatar
3 Answers
+ 19
For loop depends on the elements it has to iterate But while loop depends on condition true or false
5th Dec 2020, 9:55 AM
Mohammad Hadian
Mohammad Hadian - avatar
+ 2
On Both you can perform loop and get same results but for loop is used when you know a result will be fixed number but while loop is used when you have to take input from users and results are unknown that time you use while both give same results but for is shorter , clear and simple to use
6th Dec 2020, 5:36 PM
Sayyam Jain
Sayyam Jain - avatar
+ 1
It's negligible. Use whichever you want to use.
5th Dec 2020, 9:31 AM
Ore
Ore - avatar