Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23189

Is there a way to create a break when conditions are met?

$
0
0
import turtlet = turtleWidth = int(t.numinput("Cartesain Coordinates", "Enter Width",200, minval = 200, maxval = 400))Height = int(t.numinput("Cartesain Coordinates", "Enter Height", 200, minval = 200, maxval = 400))Grid = t.textinput("Cartesian Coordinates", "Would you like a grid?")# Defualt value for numinputs (x)Default_width_value = 200# List of possible (x) valuesPossible_width_value1 = 250Possible_width_value2 = 300Possible_width_value3 = 350Max_width_value = 400# Starting the gridif Grid == 'No':    t.goto(0, 0)if Grid == 'Yes':    Grid = True    while True:        # The Outter Square        t.penup()        t.goto(-Width, +Height)        t.pendown()        t.goto(-Width, -Height)        t.goto(+Width, -Height)        t.goto(+Width, +Height)        t.goto(-Width, +Height)    # The Inner Lines For Width (x) portion of Grid    # First Line        t.goto(-Width, -Height)        t.forward(50)        t.pendown()        t.left(90)        t.forward(+Height)        t.forward(+Height)    # Second Line        t.right(90)        t.forward(50)        t.right(90)        t.backward(-Height)        t.backward(-Height)# Third Line        t.left(90)        t.forward(50)        t.left(90)        t.forward(+Height)        t.forward(+Height)    # Fourth Line        t.right(90)        t.forward(50)        t.right(90)        t.backward(-Height)        t.backward(-Height)    # Fifth Line        t.left(90)        t.forward(50)        t.left(90)        t.forward(+Height)        t.forward(+Height)    # Sixth Line        t.right(90)        t.forward(50)        t.right(90)        t.backward(-Height)        t.backward(-Height)    # Seventh Line        t.left(90)        t.forward(50)        t.left(90)        t.forward(+Height)        t.forward(+Height)        breakif Width > Default_width_value < Possible_width_value1:        # First Line        t.right(90)        t.forward(50)        t.right(90)        t.backward(-Height)        t.backward(-Height)

First id like to say that im very new to python

The issue is when creating a grid for a cartesian coordinate, i can get it to create the grid at the minval() but once i start increasing in increments of 50 till maxval() is where i have trouble. ive tried to put the if() in the while loop, which is where i found the problem, ive also tried it out side which is where it worked fine whilest increasing in incraments of 50 but the issue i had there was it would still try and draw part of the grid even if the user said no to the grid. Its for an assinment and i can only use whats in the turtle module. Any help is very much appreciated.


Viewing all articles
Browse latest Browse all 23189

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>