Python 2.7.10: Adding 1 to global variables between functions -


so code this:

global i_like_dem_apples i_like_dem_apples = 0 global i_dont_like_dem_apples  i_dont_like_dem_apples = 0  def how_do_you_like_them_applez(steve_jobs):     if steve_jobs == "empire" or steve_jobs == "gala":         return i_like_dem_apples == i_like_dem_apples + 1      if steve_jobs == "rome" or steve_jobs == "york":         return i_dont_like_dem_apples == i_dont_like_dem_apples + 1      else:         return i_dont_like_dem_apples == i_dont_like_dem_apples + 1  def good_day (the_good_stuff):     apple in the_good_stuff:         how_do_you_like_them_applez(apple)     if i_dont_like_dem_apples > i_like_dem_apples or i_dont_like_dem_apples == i_like_dem_apples:         return "false"      if i_like_dem_apples > i_dont_like_dem_apples:         return "true"  good_day(["gala", "york", "rome"]) print i_like_dem_apples  print i_dont_like_dem_apples 

when run this, no error messages, instead this:

0  0  [finished in 0.0s] 

what hoping is:

1  2 

i've tried changing code around adding 1 bit,

def how_do_you_like_them_applez(steve_jobs):     if steve_jobs == "empire" or steve_jobs == "gala":         return i_like_dem_apples =+ 1      if steve_jobs == "rome" or steve_jobs == "york":         return i_dont_like_dem_apples =+ 1      else:         return i_dont_like_dem_apples =+ 1 

and this

def how_do_you_like_them_applez(steve_jobs):     if steve_jobs == "empire" or steve_jobs == "gala":         return i_like_dem_apples = i_like_dem_apples + 1      if steve_jobs == "rome" or steve_jobs == "york":         return i_dont_like_dem_apples = i_dont_like_dem_apples + 1      else:         return i_dont_like_dem_apples = i_dont_like_dem_apples + 1 

but invalid syntax error message. i'm pretty sure things wrong global variables, wouldn't because that's how thought global variables worked.

  1. get rid of global things, use them incorrectly.
  2. edit add global i_like_dem_apples,i_dont_like_dem_apples involved functions.
  3. replace return i_like_dem_apples == i_like_dem_apples + 1 , similar statements i_like_dem_apples += 1.
  4. fix variable names, i_like_dem_apples horrible name.
  5. do not return "false" , "true", return false , true.

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -