Skip to content
Advertisement

How do I assign a value inside list comprehension

I write a small program using comprehension list python and I need to assign a value to dictionary.

It gives me syntax error.

JavaScript

It says “[” was not closed.

Could you please help me.

Advertisement

Answer

Just inspired by earlier post, you can also do this way:

Of course, Counter is the best to do quick tallying.

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement