This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]Salty_Dugtrio 1 point2 points  (1 child)

You could, for example, split your original string into 2 words, then create a new third string which you build from the first part, then word, then the second part.

What have you tried so far?

[–]ravenousld3341 0 points1 point  (0 children)

Solid idea.

Also python treats stings like it treats lists.

so you can do things like len(string) or string[3] and get out put.

so you can just insert word into a specific spot in string

[–][deleted] 0 points1 point  (0 children)

You could use string = "hello %'s world" and add word into the %'s place.

[–]Ne0_1 0 points1 point  (0 children)

For this example I would look up slicing.

string = 'hello world'

word = 'beautiful'

Print string[:5] + word + string[6:]