+ 4
String 1 to 2
Please how can I convert string âstrâ to âstr1â Please note, I do not Inted to print It but assign It to a variable. Str = âthis is worderfulâ Iâll like to have str1 = âthis! Is! Wonderful!â
5 RĂ©ponses
+ 15
Like so:
str ="this is worderful"
str1 = "! ".join(str.split()) + '!'
print(str1)
+ 8
it is also possible to use a for loop:
txt = 'this is wonderful'
lst = txt.split(' ')
txt1 = ''
for i in lst:
txt1 += i + '! '
print(txt1)
+ 1
str="this is wonderfull"
str1="!".join(str.split(" "))
print(str1 )
+ 1
new_str = ' '.join(map(lambda x: f'{x}!', str.split()))
0
ĐĐžŃ
аОл ĐĐŸŃŃĐ°ĐœŃĐș thanks a lot.