Вот код, который должен создавать график:
from tkinter import Tk, Canvas, Frame, BOTH
from math import *
from re import *
win = Tk()
win.geometry('500x500')
win.resizable(False, False)
c = input()
x = []
if search(r'\bsqrt\b', c):
a = search(r'\d*', c)
for i in range(501):
x.append((i+3))
x.append(400 - (sqrt(i)*a[0]))
canvas = Canvas()
canvas.create_line(3, 400, 503, 400, fill = 'red', width = 2)
canvas.create_line(3, 400, 3, 0, fill = 'red', width = 2)
canvas.create_polygon(x, outline = 'red', fill = 'white', width = 2)
canvas.pack(fill=BOTH, expand=1)
win.mainloop()
Возникает такая ошибка при введении 2sqrt:
Traceback (most recent call last):
File "C:\Python32\aert", line 23, in <module>
canvas.create_polygon(x, outline = 'red', fill = 'white', width = 2)
File "C:\Python32\lib\tkinter\__init__.py", line 2191, in create_polygon
return self._create('polygon', args, kw)
File "C:\Python32\lib\tkinter\__init__.py", line 2166, in _create
cnf = args[-1]
IndexError: tuple index out of range
Как исправить ошибку, если не сложно - с объяснением