简体   繁体   中英

Python - Remove brackets, commas and quotation marks in a representation of a list

I've looked at previous entries and they're relatively difficult to understand because of the code people have used. I've used the join function but it's not working. I am trying to join a list of lists into a single string, the output should have each joined sublist separated by a space:

Five = 5

Converted = [chr(i) for i in addof]

#converts the numbers into letters of a not mentioned here variable(addof)

grouped = [converted[i:i+five] for i in range(0, len(converted), five)]

#groups the letters into groups of five

print("".join(map(str, grouped)))

#trying to use the join function in order to remove brackets etc. but it doesnt work

####################### OUTPUT ######################

['V', 'r', 'p', 'h', 'z']['k', 'h', 'u', 'h', 'l']['q', 'o', 'd', 'P', 'd']['q', 'f', 'k', 'd', '/']['l', 'q', 'd', 's', 'o']['d', 'f', 'h', 'z', 'k']['r', 'v', 'h', 'q', 'd']['p', 'h', 'L', 'g', 'r'] 

Can anyone please help? Thanks

尝试:

[''.join(x) for x in grouped]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM