66 self.fitness += 10
67 self.place_fruit()
68 else:
69 tail = self.snake[-1] 70 self.snake = self.snake[:-1, :]
71
72 self.snake = np.concatenate([[new_head], self.snake], axis=0)
4
5stringOne = input("Please enter a string: ")
6def transform_string():
7 alphabet = "abcdefghijklmnopqrstuvwxyz" 8 alphaLength = [1, 2, 3, 4, 5, 6, 7 ,8 ,9 ,10 ,11 ,12 ,13 ,14 ,15 ,16 ,17 ,18 ,19 ,20 ,21 ,22 ,23 ,24 ,25 ,26]
9 if stringOne in alphaLength:
10 print(stringOne)
An unused variable takes up space in the code, and can lead to confusion, and it should be removed. If this variable is necessary, name the variable _
to indicate that it will be unused, or start the name with unused
or _unused
.
def update():
for i in range(10): # Usused variable `i`
time.sleep(0.01)
display_result()
def update():
for _ in range(10):
time.sleep(0.01)
display_result()