Python Tricks 101

Tram Ho

Here are a few tips when working with python, hopefully it will help your work

Swap the values ​​of two variables:

Create a string from all the elements in the list:

Find the value that appears the most in the array:

Reverse a string:

Reverse a list:

Find the displacement matrix of a 2-dimensional array:

Chained Comparison:

Chained function call:

Depending on the condition, different functions will be called, but these two functions must have the same parameters.

Copy a list:

Sort values ​​in dictionary by value:

For else

Include dictionary:

And there are many more tips, readers can check out here

Chia sẻ bài viết ngay

Nguồn bài viết : Viblo