1,105,310 Community Members

def f () / loop question

Member Avatar
zentechsupport
Newbie Poster
1 post since Jul 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I am just learning python. I am switching from visual basic so this is a bit new to me. I am trying to write a loop for a super small script. It is below I am trying to understand the def f() how to loop that short code over and over until it hits an obstacle. I understand this is UBER NOOB stuff but I have been looking on google for like an hour and on here for a while but still dont understand the def f(). I saw tons of examples of it used for other purposes but didn't get how to use it for a small loop. Please help and possibly explain the syntax a bit if you can because I keep getting syntax errors when im using it. Thanks


while look () == Void:
forward ()
left ()

Member Avatar
arkoenig
Practically a Master Poster
691 posts since Jun 2010
Reputation Points: 340 [?]
Q&As Helped to Solve: 110 [?]
Skill Endorsements: 9 [?]
 
0
 

Please post your entire program, using code tags, and tell us what is happening that you don't expect.

Member Avatar
woooee
Posting Maven
2,793 posts since Dec 2006
Reputation Points: 783 [?]
Q&As Helped to Solve: 836 [?]
Skill Endorsements: 12 [?]
 
1
 

while look () == Void:
will loop indefinitely when they are not equal because the contents of the variable Void and the function look() don't change. You might want to send some variable to look() and return something other than the value of the Void when you want to exit. Functions explained http://greenteapress.com/thinkpython/html/book004.html#toc28

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: