Join method in Python
Join method in Python applied on a list of names:
mylist = ["abdur", "rehman", "qadeer", "cats", "dogs"]
oneLiner = " & ".join(mylist)
print(oneLiner)
The above code returns the following;
abdur & rehman & qadeer & cats & dogs
Join method in Python applied on a list of numbers:
mylist = [str(i*7) for i in range(1, 11)]
mylist = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]
newlist ="\n".join(mylist)
print(newlist)
The above code returns the following;
7
14
21
28
35
42
49
56
63
70
Comments
Post a Comment
Write something to CodeWithAbdur!