String concatenation with a for loop - Python Discussions
Nov 26, 2024 ... Hello everyone, When I run this program on Python 3.12.6, debian trixie: # Part 1 def test(): s = 'a'*1_000_000 t = '' for c in s: ...
Nov 26, 2024 ... Hello everyone, When I run this program on Python 3.12.6, debian trixie: # Part 1 def test(): s = 'a'*1_000_000 t = '' for c in s: ...
str() is redundant, as f.read() on a text-mode file will by definition return a string. The loop variable i name can be confusing, since it looks like a counter but is actually a string match. You might want to name it something more descriptive, like paragraph_text.
Jan 3, 2023 ... join() on a string literal. I remember ages ago when we were debating how to add a string join function, there were arguments to making it ...
I want to remove rackets and appostrophes from the list. Ex. list = [3,4,5,] result is = 3,4,5 I tried copy many code but the best i got is = ‘3,4,5’ Please help…thanks.its a list that is the active object going into the string join() method.
Jan 23, 2020 ... I want to use str.join to directly construct multi-line strings, i.e.: "\n".join( "line1", "line2", ) but because only an iterable is ...
Possible causes include disabled JavaScript or failure to load scripts or stylesheets.Python source code and installers are available for download for all versions! Latest: Python 3.15.2.
Feb 21, 2023 ... join() . The latter is a low level operation on arbitrary sequences/iterables, which are expected to provide string elements (not providing ...
You should have been redirected. If not, click here to continue.
Jul 11, 2026 ... Have you tried moving "|".join(d) outside the loop or compiling the regex ahead of time ( re.compile )?. inventshah ( ...