Skip to content

Instantly share code, notes, and snippets.

@mayankdawar
Created June 24, 2020 06:34
Show Gist options
  • Save mayankdawar/111cc63b2718b4eb348a3fe8797fedc4 to your computer and use it in GitHub Desktop.
Save mayankdawar/111cc63b2718b4eb348a3fe8797fedc4 to your computer and use it in GitHub Desktop.
# Write a function, length, that takes in a list as the input. If the length of the list is greater than or equal to 5, return “Longer than 5”. If the length is less than 5, return “Less than 5”.
def length(lst):
if len(lst) >= 5:
return("Longer than 5")
else:
return("Less than 5")
@hadrocodium
Copy link

"""
Write a function, length, that takes in a list as the input. If the length of the list is greater than or equal to 5, return “Longer than 5”. If the length is less than 5, return “Less than 5”.
"""

def length(lst):
    if len(lst) >= 5:
        return 'Longer than 5'
    return 'Less than 5'

@dionmmutarisi
Copy link

dionmmutarisi commented Oct 22, 2023

def length(lst):
tot = 5
for i in lst:
if len(lst) >= tot:
return "Longer than 5"
else:
if len(lst) <= tot:
return "Less than 5"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment