I cannot add a square of a number in python dictionary as values

1355 views python-2.7
2

I just wrote a small program to write the square of a number into a dictionary as dictionary value.

a=int(raw_input(“How many numbers do you want to print”))
b=range(a)
c={}

for i in b:
    c[i]=i*i

print c

It gives me this error.

 File "1.py", line 3
    a=int(raw_input(“How many numbers do you want to print”))
                    ^
SyntaxError: invalid syntax

Can anybody please help as I am very new to python.

answered question

1 Answer

3

This line of code:

a=int(raw_input(“How many numbers do you want to print”))

You may have copied it from somewhere else.

Try removing the double quotes and adding it again using your own keyboard. This way the right format of the character "Double Quote" will be inserted.

posted this

Have an answer?

JD

Please login first before posting an answer.