Python error "Python: can't assign to literal"

+1 vote

I am trying to run very simple code in python. 

I am getting an error on this

a = 2, b =4
Jun 17, 2019 in Python by Ramya
7,581 views

2 answers to this question.

+1 vote

The way you're assigning variables is not correct. This way is perfect for java or C but not for python. try something like this:

a, b, = 2, 4

or

a = 2
b = 4
answered Jun 17, 2019 by Priya
thank you very much, I spent a lot of time stuck in this problem.
Glad to help.. Upvote the answer, if it's helped you :)
desplega el siguiente  error

SyntaxError: cannot assign to literal

row = [1 + r for 1 r in zip(row + k,k + row)]

apreciare cualquier ayuda que me indique el camino

Hey hola @Luis,

¿Podría por favor dar más detalles sobre lo que está tratando de hacer? ¿Para que pueda guiarte de la manera adecuada?

¿No se puede asignar un error literal en Python?

1 = valor es una asignación a un literal, lo que no tiene sentido

1, 2, 3, ... son identificadores no válidos en python porque, en primer lugar, son objetos enteros y, en segundo lugar, en python un nombre de variable no puede comenzar con un número.

La forma que ha asignado no es correcta, ya que el bucle debe usarse de manera diferente. He dado un ejemplo a continuación

row=[]
for i in zip(row + k,k + row)]
 
0 votes
a, b = 2, 4 for integers

a, b = '2', '4' for strings
answered Jul 28 by vijay

Related Questions In Python

+1 vote
8 answers

How to fix this? ValueError: invalid literal for int() with base 10 error in Python

Just for the record: >>> int('55063.000000') Traceback (most recent ...READ MORE

answered Aug 17 in Python by pakainfo
• 200 points
161,765 views
+1 vote
1 answer

How to print an error in Python?

For Python 2.6 and later and Python ...READ MORE

answered Aug 23, 2018 in Python by Priyaj
• 57,680 points
679 views
0 votes
1 answer

Pyplot error "only size-1 arrays can be converted to Python scalars"

You can plot the chart by taking ...READ MORE

answered Jan 28, 2019 in Python by Omkar
• 69,030 points
7,828 views
0 votes
1 answer

What to do when I get and error saying python not recognized as internal or external command?

You need to set up the path ...READ MORE

answered May 28, 2019 in Python by Fata
• 1,050 points
322 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,453 views
0 votes
0 answers
+4 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,800 points
1,085 views
0 votes
2 answers

Python error "TypeError: Can't convert 'int' object to str implicitly"

A TypeError can occur if the type ...READ MORE

answered Feb 5 in Python by lovelmark
• 160 points
1 flag 3,449 views
0 votes
1 answer

Python error "error: Unable to find vcvarsall.bat"

Try specifying mingw as the compiler of choice. ...READ MORE

answered May 29, 2019 in Python by Imran
1,381 views