0

I need to recursively write a function that determines if a prefix, for example 'f', is the prefix of a string. If it is the prefix, it needs to return True, and if it is not the prefix, it needs to return False. How do I do this?

1 Answers1

6

Use the startswith() method :

if string.startswith(prefix):
    # do something
Leonard
  • 2,510
  • 18
  • 37
AkaSh
  • 486
  • 4
  • 16