# Define a procedure, is_friend, that takes # a string as its input, and returns a # Boolean indicating if the input string # is the name of a friend. Assume # I am friends with everyone whose name # starts with either 'D' or 'N', but no one # else. You do not need to check for # lower case 'd' or 'n' def is_friend(name): if name[0] == 'D': return True else: if name[0] == 'N': return True else: return False #print is_friend('Deborah') #print is_friend('Narita') #print is_friend('Freddy') def is_friend(name): return name[0] == 'D' or name[0] == 'N' #print is_friend('Deborah') #print is_friend('Narita') #print is_friend('Freddy') #Practicing or print True or False print True or True print False or False print False or True
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question