defwho_likes_this(names:list)->str:who='no one'number_of_likes=len(names)ifnumber_of_likes>0andnumber_of_likes<3:who=' and '.join(names)elifnumber_of_likes>=3:who=', '.join(names[:2])who+=' and '+(names[2]ifnumber_of_likes==3elsef' and {len(names[2:])} others')returnf'{who} like{""ifnumber_of_likes>1else"s"} this'
fromtypingimportListdeflikes(names:List[str])->str:messages={0:'no one likes this',1:'%s likes this',2:'%s and %s like this',3:'%s, %s and %s like this'}message=messages.get(len(names))ifnotmessage:return'%s, %s and %d others like this'%(*names[:2],len(names)-2)returnmessage%tuple(names)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
For Python
Test it:
Here's my version :)