473,387 Members | 1,882 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

can't assign to a literal error shows up

cant assign to a literal error shows up. what am i doing wrong here please
Expand|Select|Wrap|Line Numbers
  1. varA=5, varB='a'
  2. if type(varA) == str or type(varB) == str:
  3.     print('string involved')
  4. elif varA > varB:
  5.     print('bigger')
  6. elif varA == varB:
  7.     print('equal')
  8. else:
  9.     # If none of the above conditions are true,
  10.     # it must be the case that varA < varB
  11.     print('smaller')
Feb 13 '13 #1
1 2047
bvdet
2,851 Expert Mod 2GB
You cannot make assignments on one line separated by a comma.
Expand|Select|Wrap|Line Numbers
  1. >>> varA=5,varB=6
  2. Traceback (  File "<interactive input>", line 1
  3. SyntaxError: can't assign to literal
  4. >>> varA=5
  5. >>> 
You could do it like this:
Expand|Select|Wrap|Line Numbers
  1. >>> varA, varB = 5, 'a'
  2. >>> varA
  3. 5
  4. >>> varB
  5. 'a'
  6. >>> 
Feb 13 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Me | last post by:
Hi Folks I keep recieving the following error message when i try to bind a combobox to the value that is in a textbox. the application crashes on the following line... Me.CBoxTitle.SelectedItem...
7
by: Chris Wertman | last post by:
I am so lost on this one. Dim Ary as Integer = New Integer(4) {0,1,2,3} FAILS with the error: Array initializer has 1 too few elements. So I try Dim Ary as Integer = New Integer(3)...
1
by: JC | last post by:
In my Crystal Report Viewer control properties, the reportsource field is not enabled and will not allow me to insert a reportsource. I have also tried to code in the reportsource but get an error....
2
by: Usarian Skiff | last post by:
I execute most of my applications on one of two machines. They are basically identical with two exceptions, one I develope on, the other has a sql server desktop database running on it. My...
1
by: annbb | last post by:
I have a piece of code which resets all the control on a form ..but if I also put an option group on the form and the relevant code in the routine to reset it I get an error message saying that...
4
by: Avi | last post by:
Hi I am creating web application in which i want to assign by default values to the property which i had created my own. In that one of the property is of type color and i am unable to assign...
9
by: gvanosdol | last post by:
When on my development machine, I can execute the code in the subject (string strVarArr = strVar.Split('x');) without any problems. When I try to move the code to my server, I get "CS1011: Empty...
2
by: wwolfson | last post by:
Hiya, Im trying to embed some Javascript into some xhtml which is embedded into a php file. The line causing a problem is this: <form id=\"deletetopic\" name=\"deletetopic\" method=\"post\"...
1
by: bittuphilip | last post by:
Hi this is Bits here My Question is When i try to run my prog.it is giving an exception. i.e can't assign to Literal.Could you tell me why? the error msg is: Syntax Error :Can't Assign to...
7
by: scharnisto | last post by:
hi, i am trying to get this to work. it works fine so far. only when i try to loop through the list, i get an error. any suggestions? orig_file = open ("*Strata1CombinedAll.txt", "r") lines...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.