Advertisement
ganiyuisholaafeez

Find Function

Feb 19th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. """ This is a function called find_my_letter to search for the index of
  2. the first occurence of a character in a string """
  3. # This function accepts two arguments
  4. def find_my_letter(string, char):
  5.  
  6. # using the find method to search for the index of a character in the string
  7.     find_letter = string.find(char)
  8.  
  9. # Returning the index of the character
  10.     return find_letter
  11.  
  12. # Function Invokation
  13. print(find_my_letter("dangerous", "a"))
  14. print(find_my_letter("bazooka", "z"))
  15. print(find_my_letter("lollipop", "z"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement