•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 456,555 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,473 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser: Programming Forums
Views: 1361 | Replies: 5 | Solved
![]() |
•
•
Join Date: Oct 2007
Posts: 30
Reputation:
Rep Power: 2
Solved Threads: 0
Hi, My friends,
I am new to python. I try to figure out how python knows the end of loop or the end of a block of codes in while... else code
Here is the example:
while E:
Bt
else:
Bf
here if Bf have 20 lines of code. How the python knows which line of code is the end of else:
It looks like I miss something, which is quite different from all other languages.
Thanks in advance.
John
I am new to python. I try to figure out how python knows the end of loop or the end of a block of codes in while... else code
Here is the example:
while E:
Bt
else:
Bf
here if Bf have 20 lines of code. How the python knows which line of code is the end of else:
It looks like I miss something, which is quite different from all other languages.
Thanks in advance.
John
•
•
Join Date: Oct 2007
Posts: 24
Reputation:
Rep Power: 2
Solved Threads: 4
Hi,
In python, blocks structure rely on indentation
In python, blocks structure rely on indentation
while E:
Bt
else:
Bf
back to the while level•
•
Join Date: Oct 2007
Posts: 30
Reputation:
Rep Power: 2
Solved Threads: 0
•
•
•
•
Hi,
In python, blocks structure rely on indentation
while E: Bt else: Bf back to the while level
Thanks a lot. But this is kind of risky for a large project as you may have many loop and if to have indentations.
John
•
•
Join Date: Sep 2007
Posts: 19
Reputation:
Rep Power: 2
Solved Threads: 2
•
•
•
•
Thanks a lot. But this is kind of risky for a large project as you may have many loop and if to have indentations.
John
Not really. For your large project you factor and re-factor the code, to improve maintainability which also improves readability.
People have add-hoc rules like "a function should fit on a screen", or "excessive textual nesting of loops and conditionals is bad"; they are good for any language. It usually means looking at a large function and finding out why it is large with a view to encapsulating some of its functionality in another function that will be called instead.
- Paddy.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Python Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Which IDE do you recommend??? (Python)
- Tic-Tac-Toe (C++)
- Error in output (C)
- Code analysis (C++)
- how to use sorting algorithm (Java)
- Fibonacci Problem Help!! (Python)
- very 1st python tutorial 4 newbies (Python)
- Question about java.lang.UnsatisfiedLinkError in MMAPI (Java)
- My yahoo client. Not receiving data in real time :(( Just need a bit of advice (Perl)
- series of 1 + 1/2 + 1/3 ...etc (C++)
Other Threads in the Python Forum
- Previous Thread: convert to string: list with integers and strings
- Next Thread: For loops with number



Linear Mode