Python Forum
Why does Python not use parenthesis to contain loops?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why does Python not use parenthesis to contain loops?
#1
I'm following along with the MIT online course. I am a very elementary programmer, but I have some really basic knowledge of c++ and c#. Then I have a little more in depth knowledge of Powershell. I've been writing scripts in Powershell for about a year now. But, with any loop, typically you do something like this...

for (i=0; i<5; i++) {
do this first
do this second
do this third
}

But, I put in curley braces to contain the loop. Curley braces or parenthesis don't seem to work at all in Python. I tried adding them to a loop and I got an error. How does it know where the loop ends and the next code not part of the loop starts? Is it done purely on indentation?
Reply


Messages In This Thread
Why does Python not use parenthesis to contain loops? - by davidorlow - Jun-08-2021, 10:48 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Why both loops don't work in python? nau 3 2,013 Sep-21-2022, 02:17 PM
Last Post: rob101
  Python for loops Kristenl2784 3 69,262 Jun-16-2020, 06:01 PM
Last Post: Yoriz
  For loops in python Boinbo 3 124,132 Apr-18-2020, 01:23 AM
Last Post: buran
  For loops help, using python turtle SemiBeginnerPY 2 7,142 Mar-10-2020, 10:46 AM
Last Post: SemiBeginnerPY
  parenthesis around a tuple of literals in a for Skaperen 2 2,913 Aug-25-2019, 03:00 AM
Last Post: Skaperen
  Parenthesis in User-Defined Functions giorgitsu 2 2,736 Aug-07-2019, 12:56 PM
Last Post: ThomasL
  a Word Inside Parenthesis in Class Decleration tahasozgen 2 3,330 Dec-18-2018, 05:59 AM
Last Post: Gribouillis
  Escaping whitespace and parenthesis in filenames jehoshua 2 12,036 Mar-21-2018, 09:12 AM
Last Post: jehoshua

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020