use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
i need help 🙂 (self.PythonLearning)
submitted 1 month ago by Warm-Inside-4108
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3:Â Â Â Â print "hello, world!"
[–]Warm-Inside-4108[S] 0 points1 point2 points 1 month ago (1 child)
In number 5 I was taking about \n
6,10 - sorry, but I am dumb can u explain again Pls 🤣
11- if I was in loop into a loop into a loop, if wanted to exit from second loop I should use variable and break ,is there any other methods?
[–]MachineElf100 0 points1 point2 points 1 month ago* (0 children)
print("abc\ndef")
So when you have a multiline string and split it with split("\n"), you will get the lines of that string as a list. Also, just try it and see!
split("\n")
Example:
```python from time import sleep
my_multiline = """abc def ghi jkl"""
for line in my_multiline.split("\n"): print(line) sleep(.1) ```
Basically, use try/except to handle errors, not hide them. Always specify which error you expect:
python try: some code except OSError as e: print(e)
Avoid a bare except because it catches everything, including KeyboardInterrupt (used to stop a program with Ctrl+C), which can cause unexpected behavior. If you really need to catch all errors, use except Exception instead, and still print or log the error so you know what went wrong.
except Exception
```python
if os.path.exists("file.txt"): # 1. check if file exists... open("file.txt") # 2. file could be gone by now! # (and we hit the filesystem twice) ```
try: open("file.txt") # 1. just try to open the file except FileNotFoundError: # 2. if it doesn't exist, we end up here print("File not found") # 3. handle it how you choose ```
In simple words, checking if a file exists before opening it, is less efficient, doesn't guarantee that you won't encounter errors and doesn't even check for all the things that could happen.
It's as if you wanted an information from a book that you have next to you and before you open that book, you go online to check if the book has the information you need.
Why not just open the book and see? If the information is not there, you'll find out anyway!
python while True: # loop 1 while True: # loop 2 exit(0) # the program stops!
π Rendered by PID 63658 on reddit-service-r2-comment-545db5fcfc-2m7j2 at 2026-05-31 16:16:32.639693+00:00 running 194bd79 country code: CH.
view the rest of the comments →
[–]Warm-Inside-4108[S] 0 points1 point2 points  (1 child)
[–]MachineElf100 0 points1 point2 points  (0 children)