How to fix this error with tkinter keys?

Please help!
In Python I get the error message:
Traceback (most recent call last):
 File "/Users/zackary/Python/My game "Ran-Ran"/Os.Code.py", line 49, in <module>
 c.bind('<space>', jump_player)
 File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tkinter/__init__.py", line 1248, in bind
 return self._bind(('bind', self._w), sequence, func, add)
 File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tkinter/__init__.py", line 1203, in _bind
 self.tk.call(what + (sequence, cmd))
_tkinter.TclError: bad event type or keysym "space"


And the code itself:
import random
from tkinter import Canvas, Tk, messagebox font
root = Tk()
c = Canvas(root, width = 800, height = 500, background = 'deep sky blue')
c.create_rectangle(-5, 400, 805, 505, fill = 'gray', width = 0)
c.pack()
boxes = []
clouds = []
cloudsspeed = []
player = object

def create_player():
 player = c.create_rectangle(120, 360, 240, 140, fill='blue', outline='#ff0000', width = 6)

create_player()

def jump_player():
 c.move(player, 0, 160)

def create_box (size = 80, x = 800, y = 400):
 y -= size/2
 new_box = c.create_rectangle(x-size/2, y+size/2, x+size/2, y-size/2, fill='brown', outline='#d88c00', width = 6)
boxes.append(new_box)
 root.after(random.randint(size*25 size*75), create_box)

def move_boxes (speed = -40):
 for box in boxes:
 (your box_x, box_y, box_x2, box_y2) = c.coords(box)
 c.move(box, speed, 0)
 root.after(500, move_boxes)

def create_clouds(sizeX = random.randint(40,120), sizeY = random.randint(20,100), x = 800, y = 20):
 sizeY = random.randint(20,100)
 sizeX = random.randint(40,120)
 y = random.randint(10,80)
 new_cloud = c.create_oval(x-sizeX/2, y+sizeY/2, x+sizeX/2, y-sizeY/2, fill='white', outline='#18ffff', width = 3)
clouds.append(new_cloud)
cloudsspeed.append(random.randint(5,40))
 root.after(random.randint(1000,6000), create_clouds)

def move_clouds():
 i = 0
 for cloud in clouds:
 (cloud_x, cloud_y, cloud_x2, cloud_y2) = c.coords(cloud)
 c.move(cloud-cloudsspeed[i], 0)
 i += 1
 root.after(500, move_clouds)

c.bind('<space>', jump_player)
c.focus_set()

create_box()
move_boxes()
create_clouds()
move_clouds()
root.mainloop()
April 7th 20 at 10:56
1 answer
April 7th 20 at 10:58
Solution
space
There is still error:
Traceback (most recent call last):
 File "/Users/zackary/Python/My game "Ran-Ran"/Os.Code.py", line 49, in <module>
 c.bind('<space>', jump_player)
 File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tkinter/__init__.py", line 1248, in bind
 return self._bind(('bind', self._w), sequence, func, add)
 File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tkinter/__init__.py", line 1203, in _bind
 self.tk.call(what + (sequence, cmd))
_tkinter.TclError: bad event type or keysym "space"
- Alvis commented on April 7th 20 at 11:01
@Domenica, you have trouble with care... you instead of the English letters "c" Russian letter "with". - helen_Gerhold11 commented on April 7th 20 at 11:04

Find more questions by tags Python