Python while loops are used when a set of actions needs to be performed until a condition becomes false.
In the below code, you can see, the print statement gets executed until the condition becomes false. i.e the value of the counter is increasing and when it becomes equal to “5”, then the printing stops, hence the last value printed is “4”.
Farukh is an innovator in solving industry problems using Artificial intelligence. His expertise is backed with 10 years of industry experience. Being a senior data scientist he is responsible for designing the AI/ML solution to provide maximum gains for the clients. As a thought leader, his focus is on solving the key business problems of the CPG Industry. He has worked across different domains like Telecom, Insurance, and Logistics. He has worked with global tech leaders including Infosys, IBM, and Persistent systems. His passion to teach inspired him to create this website!