Hello Python Tutor, We are trying to use the random function in the Tkinter module in PyCharmEDU 3.5. (on Macs running 10.11.6). However, we get a number of error messages:
Here's the code: from tkinter import * import random tk = Tk() canvas = Canvas(tk, width=400, height=400) canvas.pack() def random_randrange(height): pass def random_randrange(width): pass def random_rectangle(width, height): x1 = random_randrange(width) y1 = random_randrange(height) x2 = x1 + random.randrange(width) y2 = y1 + random.randrange(height) canvas.create_rectangle(x1, y1, x2, y2) random_rectangle(400, 400) tk.mainloop() Here are the error messages: Traceback (most recent call last): File "/Users/lwaters/PycharmProjects/tkinternew/rectangles.py", line 2, in <module> import random File "/Users/lwaters/PycharmProjects/tkinternew/random.py", line 17, in <module> randomRects(100) File "/Users/lwaters/PycharmProjects/tkinternew/random.py", line 10, in randomRects x1 = random.randrange(150) AttributeError: module 'random' has no attribute 'randrange' Process finished with exit code 1 Your advice is greatly appreciated! Lisa Waters -- Lisa Waters, PhD Technology Integration Middle School Coding Lower School Digital Literacy Flint Hill School 703.584.2300 *www.flinthill.org* <http://www.flinthill.org/> _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor