Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

einhan

  • one year ago

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'

  • This Question is Closed
  1. Shadowys
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  2. ParthKohli
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  3. ParthKohli
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  4. MicroBot
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 1

    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

  5. shawnf
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  6. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Ask a Question
Find more explanations on OpenStudy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.