![]() |
How to give space when concaneting strings - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: How to give space when concaneting strings (/thread-28339.html) |
How to give space when concaneting strings - deshanish - Jul-15-2020 >>> str='Python is a great programming language' >>> str 'Python is a great programming language' >>> str1=str[0:11] >>> str2=str[12:29] >>> str3=str[30:39] >>> newstr = str1 + str2 + str3 >>> newstr 'Python is agreat programminglanguage' >>> RE: How to give space when concaneting strings - bowlofred - Jul-15-2020 You could explicitly insert strings (either with concatenation or with f-strings), or you could join() the strings with a space.>>> s1 + " " + s2 + " " + s3 #1a 'Python is a great programming language' >>> f"{s1} {s2} {s3}" #1b 'Python is a great programming language' >>> " ".join((s1, s2, s3)) #2 'Python is a great programming language' |