Advertisement
Guest User

Untitled

a guest
Mar 20th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. # 2D List
  2.  
  3. def negate(L):
  4. result = L
  5. for row in range(len(result)):
  6. for col in range(len(result[row])):
  7. result[row][col] = result[row][col] * 2
  8. return result
  9.  
  10. print(negate([[1,2,3],[1,2,3],[1,2,3]]))
  11.  
  12. # Recursive function
  13.  
  14. def merge_characters (chars: 'list of strings and nested lists of strings') -> str:
  15. result = ""
  16. for element in chars:
  17. if type(element) == list:
  18. result = result + merge_characters(element)
  19. elif type(element) == str:
  20. result = result + element
  21. return result
  22.  
  23. def reverse_a_string(string):
  24. if string == "":
  25. return string
  26. else:
  27. return reverse_a_string(string[1:]) + string[0]
  28.  
  29.  
  30. string = "ballsack"
  31. print(reverse_a_string("string"))
  32.  
  33. def draw_lines(n: int, cavnas: tkinter.Canvas):
  34. width = canvas.winfo_width()
  35. height = canvas.winfo_height()
  36. num_lines = int((n+1) / 2)
  37.  
  38. for i in range(num_lines):
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement