Expand|Select|Wrap|Line Numbers
- Input: ['bikes', 'cars', 'buses', 'trucks']
So I wrote the code like the below source code:
Expand|Select|Wrap|Line Numbers
- def listToString(someList):
- for i in range(len(someList)):
- newString = str(someList[i])
- if i == (len(someList)-1):
- print('and ' + str(someList[i]))
- else:
- print(newString, end=', ')
- someList = ['bikes','cars','buses','trucks']
- listToString(someList)