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

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


a = 2
b = 4

Hope this helps!!

If you need to know more about Python, join Python certification course today.


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

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

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

Related Questions In Python

+1 vote
10 answers

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

The following are totally acceptable in python: passing ...READ MORE

answered Nov 16, 2018 in Python by Nymeria
• 3,560 points
+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
• 58,090 points
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,230 points
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
0 votes
2 answers
+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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,211 views
0 votes
1 answer
+5 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,790 points
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, 2020 in Python by lovelmark
• 160 points
1 flag 18,580 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
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP