I'm terribly sorry I have to ask such a ridiculously simple question, but I've been looking for the answer for awhile now, I feel like an idiot, but I cannot seem to get this to work.
I simply want to create an array with 10 variables, each defined by the user, and then have the option to add them all together. I can't even get the first parts correctly though. Here is my code so far:
def makeArray():
a = [0,1,2,3,4,5,6,7,8,9]
a[0] = input("Please input 1st number: \n")
a[1] = input("Please input 2nd number: \n")
a[2] = input("Please input 3rd number: \n")
a[3] = input("Please input 4th number: \n")
a[4] = input("Please input 5th number: \n")
a[5] = input("Please input 6th number: \n")
a[6] = input("Please input 7th number: \n")
a[7] = input("Please input 8th number: \n")
a[8] = input("Please input 9th number: \n")
a[9] = input("Please input 10th number: \n")
def main():
makeArray()
print(a[2])
main()
Whenever I run it though after entering the 10 values I get "Global name 'a' is not defined." can anyone please help me?