I am trying to make a python script that calculates the standart deviation of numbers in a list
for i in listofnums:
total += (i - sumofnums) ** 2
result = math.sqrt(total / (len(listofnums) -1))
This is the part of the program that I'm having issues with, I cannot use the total variable for getting the result for the result variable
total += (i - sumofnums) ** 2
NameError: name 'total' is not defined
Nearly every tutorial/documentation I looked at, it shows that you can access variables like total outside the for loop
Am I doing something stupid here?