Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def likes (list_of_people) :
result = ""
length = len (list_of_people)
if length == 0 :
result = "no one likes this"
elif length == 1 :
result = list_of_people[0] + " likes this"
elif length == 2 :
result = list_of_people[0] +" and " + list_of_people[1] + " like this"
elif length == 3 :
result = list_of_people[0] + ", " + list_of_people[1] + " and " + list_of_people[2] + " like this"
else :
result = list_of_people[0] +", " + list_of_people[1] + " and " + str (length - 2) + " others " + "like this"
return result
print (likes (["Ram" , "Dinesh" , "Dev" , "Rahul" , "Ankit" , "Harsh"]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment