Q. Given a list of strings L, write a program below that prints a single string containing all of the elements of L concatenated (joined) together with a hyphen in between two elements.

 

Answer =

 

lst = eval (input("Enter a List :-"))
string = ""
for i in range (len(lst)) :
    if i == len(lst) - 1 :
        string += lst[i]
    else :
        string = string + lst[ i ] + "-"
print ("New word is :- ", string)

 

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post