Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem with for loops?
#1
This is the code:
import turtle Win = turtle.Screen() t = turtle.Turtle() def shape(length, sides): for i in (1,sides): t.forward(length) t.left(360 / sides) shape(100, 8) Win.exitonclick()
the problem is that not matter what sides is it only draws the first 2 lines of the shape
thanks in advance
Reply
#2
(Sep-26-2018, 06:33 PM)Darbandiman123 Wrote: for i in (1,sides):
I don't think that does what you think that does.

>>> for x in (1, 4): ... print(x) ... 1 4
Do you mean for i in range(1, sides)?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Fundamental understanding-problem regards to while-loops Placebo 7 6,312 Oct-11-2018, 01:18 PM
Last Post: Placebo

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.