E
Eternaltheft
Hi, I'm having trouble oh how prompt the user to enter a file name and how to set up conditions. For example, if there's no file name input by the user, a default is returned
how to set up conditions. For example, if there's no file name input by theHi, I'm having trouble oh how prompt the user to enter a file name and
Hi, I'm having trouble oh how prompt the user to enter a file name and how to set up conditions. For example, if there's no file name input by the user, a default is returned
In Python 2 it's called "raw_input" and in Python 3 it's called "input".Thanks for such a fast reply! and no im not using raw input, im just
using input. does raw_input work on python 3?
using input. does raw_input work on python 3?Thanks for such a fast reply! and no im not using raw input, im just
from user?Ok thanks guys. but when i use
filename = input('file name: ')
if not filename: #i get filename is not defined
return(drawBoard) #possible to return function when no file input
Ok thanks guys. but when i use
filename = input('file name: ')
if not filename: #i get filename is not defined
return(drawBoard) #possible to return function when no file input from user?
sorry about that, i got confused xD. yeah it works good now.
what i meant to say was can i return a function that i made, if the user inputs nothing?
filename = input('file name: ')
if not filename: #i get filename is not defined
from user?return(drawBoard) #possible to return function when no file input
sorry about that, i got confused xD. yeah it works good now.
what i meant to say was can i return a function that i made, if the user inputs nothing?
yeah i found out why it wasn't defined before because i tried to put it into a function.
this is my drawBoard function:
import turtle as Turtle
Turtle.title("Checkers")
b = 75
def drawBoard(b):
Turtle.speed(0)
Turtle.up()
Turtle.goto(-4 * b, 4 * b)
Turtle.down()
for i in range (8):
Turtle.forward(b)
Turtle.right(90)
Turtle.forward(b)
Turtle.right(90)
Turtle.forward(b)
Turtle.right(90)
Turtle.forward(b)
Turtle.right(90)
Turtle.forward(b)
for i in range (1):
Turtle.right(90)
Turtle.forward(b*2)
Turtle.right(90)
for i in range(8):
Turtle.forward(b)
Turtle.right(90)
Turtle.forward(b)
Turtle.right(90)
Turtle.forward(b)
Turtle.right(90)
Turtle.forward(b)
Turtle.right(90)
Turtle.forward(b)
for i in range(1):
Turtle.left(90)
Turtle.forward(b)
Turtle.left(90)
for i in range (8):
Turtle.forward(b)
Turtle.left(90)
Turtle.forward(b)
Turtle.left(90)
Turtle.forward(b)
Turtle.left(90)
Turtle.forward(b)
Turtle.left(90)
Turtle.forward(b)
for i in range (1):
Turtle.right(90)
Turtle.forward(b)
Turtle.right(90)
for i in range(8):
Turtle.forward(b)
Turtle.right(90)
Turtle.forward(b)
Turtle.right(90)
Turtle.forward(b)
Turtle.right(90)
Turtle.forward(b)
Turtle.right(90)
Turtle.forward(b)
for i in range(1):
Turtle.left(90)
Turtle.forward(b)
Turtle.left(90)
for i in range (8):
Turtle.forward(b)
Turtle.left(90)
Turtle.forward(b)
Turtle.left(90)
Turtle.forward(b)
Turtle.left(90)
Turtle.forward(b)
Turtle.left(90)
Turtle.forward(b)
for i in range (1):
Turtle.right(90)
Turtle.forward(b)
Turtle.right(90)
for i in range(8):
Turtle.forward(b)
Turtle.right(90)
Turtle.forward(b)
Turtle.right(90)
Turtle.forward(b)
Turtle.right(90)
Turtle.forward(b)
Turtle.right(90)
Turtle.forward(b)
for i in range(1):
Turtle.left(90)
Turtle.forward(b)
Turtle.left(90)
for i in range (8):
Turtle.forward(b)
Turtle.left(90)
Turtle.forward(b)
Turtle.left(90)
Turtle.forward(b)
Turtle.left(90)
Turtle.forward(b)
Turtle.left(90)
Turtle.forward(b)
for i in range (1):
Turtle.right(90)
Turtle.forward(b)
Turtle.right(90)
for i in range(8):
Turtle.forward(b)
Turtle.right(90)
Turtle.forward(b)
Turtle.right(90)
Turtle.forward(b)
Turtle.right(90)
Turtle.forward(b)
Turtle.right(90)
Turtle.forward(b)
drawBoard(b)
Turtle.done()
it draws an 8x8 board table.
what i initially wanted to do was to return this function if nothing was inputted from the user. i hope that makes more sense :S
do you think ti would be better if i call drawBoard?
And perhaps you meant for your function to CALL drawBoard(), rather than
returning the function object drawBoard.
DaveA
And perhaps you meant for your function to CALL drawBoard(), rather than
returning the function object drawBoard.
DaveA
do you think it would be better if i call drawBoard?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.