element = {'H': 1, 'N': 6, 'F': 7, 'Cl': 7}
i = input("Enter: ")
dots = '*'
totalDots = (dots * i)

Enter: H

Traceback (most recent call last):
File "D:/Python26/lewisdot.py", line 4, in <module>
i = input("Enter: ")
File "<string>", line 1, in <module>
NameError: name 'H' is not defined

How come?


element = {'H':1, "N":6, "F":7, 'Cl':7}
i = raw_input('Enter: ')
dots = '*'
totalDots = element[i]*dots

as mentioned in the above post you need to use the raw_input function because input reads in an integer/float value :)

masterofpuppets is right, you have to use input for numbers and raw_input for text strings. If this still doesnt work then try defining the class before putting it in the element list.