def intro():
print("This program computes payroll based on")
print("over time rate of ", overTime, " after ", workWeek, " hours")
name = input("Enter employees name: ")
hours = (int(input("Enter hours worked: ")))
rate = input("Enter rate: ")
1 Answer
Whereas it's considered to be a bad practice and in most cases you should avoid using global variables, you can use "global" to reach your variable inside the function.
Like this:
global name
name = input("string")
3 Comments
jedwards
This will certainly be a
SyntaxErrorPaul Cornelius
Don't do this. Just return
name. Then it will be accessible from the calling code.Hisagr
@jedwards Yep, I've never used such a bad code to know this for sure :). Edited the answer anyway

{ }button.run. It will not find it and it will look for the larger scope. There it should find it and run as expected. Once the variable is set as a consequence of the input, the value become local (accessible only inside the function, while outside of the function still keeping the 'Y' value. Not particularly elegant, but I don't see why it should fail (if you post the actual code as said above, we can test it).