Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
good point of not using a dictonary!
the other points should't be changed:
don't leave out the slicing of 'names' inside format(), as this results in much slower performance for long name lists.
making that if/else shorter degrades readability and performance
same goes for separating the "like(s) this" part
this would be a good approach:
out = ( 0: 'no one likes this',
1: '{} likes this',
2: '{} and {} like this',
3: '{}, {} and {} like this',
4: '{}, {} and {others} others like this'
)
def likes(names):
return out[min(4, len(names))].format(*names[:3], others=len(names)-2)
thabks heeps!
Use http://pythontutor.com/visualize.html see it for youself ;)
Also read this: https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution
This comment is hidden because it contains spoiler information about the solution