From the course: Transition from C# to Python

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Loops

Loops

From the course: Transition from C# to Python

Start my 1-month free trial

Loops

- [Instructor] Okay, let's close out our introduction to Python basics by looking at loops. Loops are of course another critical foundation of programming. And here again C# gives us a variety of loop constructs to use. So let's go ahead and open up in the Loops folder, we'll go into Loops CS and open up the program file. So probably the most common of these loops is the for loop. Now in C# we have a couple of different for loops to choose from, right? There's the old school version that uses the initializer the comparison, and then the incrementer, and we can see here this is indexing over the content of a string. And then there's the for each in version that operates on iterable objects like strings and collections. There's also the while and the do-while loops which are essentially the same except that do-while always executes at least once. And this is another area where Python prefers simplicity over variety and…

Contents