Uploaded by yanoyag888

Split and Join

advertisement
Split and Join
msg ='Welcome
to
Python
101: Split
and Join'
csv = 'Eric,John,Michael,Terry,Graham'
friends_list = ['Eric','John','Michael','Terry','Graham']
print('-'.join(friends_list))
When we split we turn something into a list
When we join we turn it into a string
If we start out with a string then create a list, then we can turn it back to string
Same same but different. The latter is simpler.
print(''.join(msg.split()))
print(msg.replace(' ', ''))
Download