How do i concatenate strings in python?
-
You can use the plus or addition operator to combine strings.
print("Ahoy " + "me " + "hearties")
Result
`>> Ahoy me heartiesYou can also combine strings using the % operator
pirate1 = "sparra" pirate2 = "skullhead" print("Ahoy! there Jack %s. %s's me name." % (pirate1, pirate2))
Result.
>> Ahoy! there Jack sparra. skullhead's me name.
© Lightnetics 2024