You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is a function called is_funny that accepts a string and returns true only if the received string is made up entirely of the characters 'h' and 'a':
def is_funny(string):
for char in string:
if char != 'h' and char != 'a':
return False
return True
Write the function is_funny so that it performs the same operation, in only one line of code.
An example of running the is_funny function:
print(is_funny("hahahahahaha"))
True
'''
import functools
# one line version
def is_funny(string):
return all(char == 'h' or char == 'a' for char in string)