Created
October 21, 2022 10:53
-
-
Save RaMSFT/7d13f2523351e75854f603f23c61c4a0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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