[Tutor] Livewires questions

Tiger12506 keridee at jayco.net
Thu Jul 26 21:33:13 CEST 2007


> Based on your guidance, I figured it out.  I need to use a return 
> statement, which I had not encountered before.  Now I wrote my 
> definitions in this way:
> 
> def collided():
>    if player_x == robot_x+0.5 and player_y == robot_y+0.5:
>       return True
 
This could be simplified more.
Here's an example as a hint. These two functions are the same.

def f():
  if a == b and c == d:
    return True

def g():
  return (a==b and c == d)


> Then I use that value in another definition like this:
> 
> def check_collisions():
>    if collided() == 1:
>       print "You have been caught"

And ~

if collided():
  print "You have been caught"


More information about the Tutor mailing list