Skip to content

Instantly share code, notes, and snippets.

@RaMSFT
Created October 21, 2022 10:53
Show Gist options
  • Save RaMSFT/7d13f2523351e75854f603f23c61c4a0 to your computer and use it in GitHub Desktop.
Save RaMSFT/7d13f2523351e75854f603f23c61c4a0 to your computer and use it in GitHub Desktop.
def list_to_string(lst):
#Given list might contain numerics also, hence, convert each element into the string
#This can be done with loops also, using map to do it here
str_list = list(map(str, lst))
#Using join to add all elements together into a string
result_str = ''.join(str_list)
return result_str
print(list_to_string([1, 2, 3, 4, 5, 6]))
print(list_to_string(["a", "b", "c", "d", "e", "f"]))
print(list_to_string([1, 2, 3, "a", "s", "dAAAA"]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment