def listToString(usersList):
    myStr = ', '.join(str(i) for i in usersList[0:-1])
myStr = myStr + ' and ' + str(usersList[-1])
print(myStr)
myList = input().split(',')
listToString(myList)
Can't get code in shell to work as a program