Answer the question
In order to leave comments, you need to log in
A beginner in programming, I decided to create a program that creates a graph of the root function. There was an error in the tkinter module. How to fix?
Here is the code that should create the graph:
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()
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
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question