0
How to add list m and k so to get a list ["ogay","veroay","heretay"] ?
string=input().replace(" ",",").split(",") h=[j.replace(j[0],"") for j in string] m=[i[0]+"ay" for i in string] k=[n+l for n in h for l in m] # k = ["o","ver","here"] # m = ["gay","oay","tay"]
11 Antworten
+ 3
Assuming <k> and <m> contain string, and have equal number of items; you can zip <k> and <m> then use f-String to glue chunks taken from each `list`
+ 1
Ipang Don't know how to do it bro
+ 1
Get to know it bro, it's quite useful ...
https://realpython.com/JUMP_LINK__&&__python__&&__JUMP_LINK-zip-function/
+ 1
Ipang Thanks bro i understand it but it's creating tuple it's not adding it.Could you tell me how to use the f-string to glue it
+ 1
Ipang Nah bro thanks i did it
+ 1
Okay good job!
Here's the f-String reference just in case ...
https://realpython.com/JUMP_LINK__&&__python__&&__JUMP_LINK-f-strings/
+ 1
Easy bro, just use join() method from `str` class
result = " ".join( lst )
You can replace the space " " with any string you want to use for gluing the `list` elements ...
+ 1
Thanks bro
0
Ipang Hey bro could you tell me how to convert a list into str i forgot
0
Give me list example, and the expected string result. I''ll see if I could help ...
0
Ipang lst=["hey","bro","hello"]
Into this
hey bro hello