• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why cant i access the variable?

 
Ranch Hand
Posts: 52
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in my footy league manager

why cant i print out userTeamName in other functions or at the end of the program...its just blank



 
warren brandt
Ranch Hand
Posts: 52
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why is this being used
userTeamName = ""

instead of this:
userTeamName = askForTeamName #team name entered by the user

after calling the mainMenu() function



 
warren brandt
Ranch Hand
Posts: 52
2
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok

so merely creating a variable outside any function...say at the top of your program...doesnt mean its a global variable

carCount = 0

def countCars():
   countCars = input("Enter number of cars")
   global carCount
   carCount = countCars

now carCount is a global variable
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic