Python problem

Asked 2 years ago, Updated 2 years ago, 82 views

Function to implement: my_join(delimiter, objects)

Use Case

seq1 = ["Hong Gil-dong", 20, True]
seq2 = ["Simcheong", None, 3.3]

print(my_join('-', seq1) # Hong Gildong-20-True
print(my_join('!!', seq2) # Simcheong!!!None!!!3.3

Please

python join

2022-09-21 10:24

2 Answers

def my_join(delimiter, objects):
    return ''.join(list(map(lambda x: str(x) + delimiter, objects)))[:-len(delimiter)]

Cheer up! (Laughing)


2022-09-21 10:24

Study hard...

def my_join(delimiter, objects):
    return delimiter.join(map(str, objects))


2022-09-21 10:24

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.