Skip to content

Latest commit

 

History

History
44 lines (24 loc) · 734 Bytes

Friend_or_Foe.md

File metadata and controls

44 lines (24 loc) · 734 Bytes

CodeWars Python Solutions


Friend or Foe?

Make a program that filters a list of strings and returns a list with only your friends name in it.

If a name has exactly 4 letters in it, you can be sure that it has to be a friend of yours! Otherwise, you can be sure he's not...

Ex: Input = ["Ryan", "Kieran", "Jason", "Yous"], Output = ["Ryan", "Yous"]

friend ["Ryan", "Kieran", "Mark"] `shouldBe` ["Ryan", "Mark"]

Note: keep the original order of the names in the output.


Given Code

def friend(x):
    pass

Solution

def friend(x):
    return [n for n in x if len(n) == 4]

See on CodeWars.com