Created
June 24, 2020 06:34
-
-
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”.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def length(lst): | |
if len(lst) >= 5: | |
return("Longer than 5") | |
else: | |
return("Less than 5") |
hadrocodium
commented
Apr 8, 2022
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