Common mistakes when programming experienced people start studying Python

Introduction

Originally, I mainly touched PHP on the server side, or C language in school classes. This time, I started studying because Python seems to be efficient as a measure for job hunting coding tests.

When I touched Python, it was too simple compared to other languages, and as it is said, it was just English. It's so simple that I'm a little confused, unlike other languages. So, I will summarize my common mistakes. I'm new to Python, so I'm looking forward to it.

Forgot to add a colon

I have a lot of this. Python forgets because it doesn't use {} in for and if statements.

How to write a for statement is completely different

Most languages

for(i=0;i<N;i++){
   #hogehoge
}

However, in python,

for i in range(0,N) :
    #hogehoge
else:
    #Processing after for is finished

It is a way of writing. It's nice to be able to write the processing after the for is finished with else!

Handling arrays is too easy

if s in str : 
    print('s is in str')
if s not in str :
   print('s in not in str')

You can write almost in English. That's why it's easy to forget the colon. .. .. Well, I'm used to it.

python is fun to write!

There is a feeling that it is different from other languages, but it is insanely fun to write. Also, the amount of description can be extremely small! !! I will study harder.

Recommended Posts

Common mistakes when programming experienced people start studying Python
[Python] Start studying
Studying python
Start python
How to start Python (Flask) when EC2 starts