You have set bam local to main program and local to function asteroidism.
bam in your main program is out of scope for your functions.
If you want to modify it from within a function, you have to either:
Pass it to the function and return it from the function
or
Make it a global variable.
Also, I would highly recommend indenting your code for readability reasons.
bam in your main program is out of scope for your functions.
If you want to modify it from within a function, you have to either:
Pass it to the function and return it from the function
or
Make it a global variable.
Also, I would highly recommend indenting your code for readability reasons.