"can't assign to function call" error python


#1

Hi,

Can you find what's wrong with this code? I'm new with pyhton.

https://pastebin.com/CZwdSa3f

I'm getting this error message and the code is simple I can't find what's wrong.


#2

Read that error message, it says exactly what's wrong

What does assignment look like?
What does a function call look like?
Look for the place in your code where you assign to a function call

Also, the is-operator doesn't test whether two values are equal. You can have two identical values where the first one isn't the other, 'n' is 'n' is not necessarily true. (Generally don't use things you haven't first found out what they do, you need some kind of promise before you rely on them (such as documentation))

You're repeating a lot of code, consider using a loop instead. Computers are really good at running the same or similar instructions multiple times.

semi-colons are very rarely used in Python. You probably don't want them where you have them.

Why are you using Counter instead of dict or set?


#3

I'm new at python, like first time ever python code. So, everything is googled first, so is semicolon using. Maybe it's from previous versions, I don't know. I have to use if-elif construction since it's necessary to test every letter for specific letter supstitution. Thanks for help and cynicism, lol


#4

You can do that in a loop, you'd iterate over the character pairs.
You can also do it without a loop by using the first character to look up the other, skipping the comparisons altogether.

If you suddenly want to change something about what you do with each pair, you could do it once, or some 20+ times because the same code has been repeated.


#5

Thanks! I will try it.


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.