Local Variable Error
Hi,
The local variable should not have been possible to access outside but in this chapter there is no error accessing local variable directly outside the scope of function even if that is not declared globally. please correct the chapter
Example of local variable
def getBandRating(bandname):
myFavouriteBand = "AC/DC"
if bandname == myFavouriteBand:
return 10.0
else:
return 0.0
print("AC/DC's rating is: ", getBandRating("AC/DC"))
print("Deep Purple's rating is: ", getBandRating("Deep Purple"))
print("My favourite band is", myFavouriteBand)
1
vote
Sandip
shared this idea