About Lesson
join( ):-
The join() method takes all items in an iterable and joins them into one string. A string must be specified as the separator.
Syntax:- string.join(iterable)
myTuple = (“John”, “Peter”, “Vicky”) x = “#”.join(myTuple) print(x) Output John#Peter#Vicky |
myDict = {“name”: “John”, “country”: “Norway”} mySeparator = “TEST” x = mySeparator.join(myDict) print(x) Output nameTESTcountry |
Note: When using a dictionary as an iterable, the returned values are the keys, not the values.