Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. def merge_lists(a, b):
  2. new_list = []
  3. for x in a:
  4. new_list.append(x)
  5. for x in b:
  6. new_list.append(x)
  7. return new_list
  8.  
  9.  
  10. def count_lower(s):
  11. """
  12. count the number of lower ascii letters in the string.
  13.  
  14. :param s: string
  15. :return: int, count of lower ascii letters
  16. """
  17. list_of_lower_letters = ""
  18. for i in s:
  19. if i.islower():
  20. list_of_lower_letters += i
  21. return list_of_lower_letters
  22.  
  23. print(count_lower("ASDsdsa"))
  24.  
  25. def ends_with_pair(s):
  26. """
  27. if string ends with pair of symbols, return the index of the start of the pair.
  28. if not, return the index of the last symbol.
  29. else, return -1
  30.  
  31. :param s: string
  32. :return: int, index of pair or index of single symbol or -1
  33. """
  34. if len(s) == 1:
  35. return 0
  36. elif s == "":
  37. return "-1"
  38. elif s[-1] == s[-2]:
  39. return len(s) - 2
  40. elif s[-1] != s[-2]:
  41. return len(s) - 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement