We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,348 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

def f () / loop question

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 ()

3
Contributors
2
Replies
6 Hours
Discussion Span
1 Year Ago
Last Updated
3
Views
zentechsupport
Newbie Poster
1 post since Jul 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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

arkoenig
Master Poster
711 posts since Jun 2010
Reputation Points: 396
Solved Threads: 110
Skill Endorsements: 7

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

woooee
Posting Maven
2,707 posts since Dec 2006
Reputation Points: 827
Solved Threads: 780
Skill Endorsements: 9

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0640 seconds using 2.72MB