Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 6 Online
OpenStudy (anonymous):

What does 'can't assign to literal' error mean? I did: '3 + 3' = 'six' print ('3 + 3') It gives me that error. I intended to get 'six' printed out, since I intended to assign 'six' to '3 + 3'

OpenStudy (anonymous):

you cannot assign a string to another string '3+3' is an illegal name because there's numbers and operators only

Parth (parthkohli):

``` var x = "y" ``` The above is the standard format for assignment.

Parth (parthkohli):

Note that it is not this: ``` var "x" = "y" ```

OpenStudy (microbot):

on the left side u have to have a variable name to assign to a string ,a number,or an other variable that has to be on the right side. so if u wanted to call your variable something like 3+3 it cant be a string ,and u cant start the variable name with a number or have an operator in it. Instead you could call it threeplusthree or threeplus3. so: threeplus3='six' should do it. :) Check this for further info: (1.6.1. Literals and Identifiers) http://anh.cs.luc.edu/python/hands-on/3.1/handsonHtml/variables.html

OpenStudy (anonymous):

you are trying to assign a value to another value you can only assign a value to a variable

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!