Afternerd Python Part(2)

This article is about python programming skills from afternerd

Check a python string contains another string

How to Check if a Python String Contains Another String?
View Larger Image

How to Check if a Python String Contains Another String?
View Larger Image

  • in operator
  • find method

advanced stuff

Difference between a List and a Tuple?

Python: What is the difference between list and tuple
Python: What is the Difference between a List and a Tuple?

The key difference between List and Tuple is:

  • list is mutable
  • tuple is immutable

advanced topics

Use timeit in Python


Python: How to use the ‘timeit’ module for multiple lines?

timeit module is a handy python module that allows you to debug the performance bottlenecks between different ways to perform a task.

3 Ways to Copy a List in Python

3 ways to copy a list in python

Copying a python list means creating a new python object whose contents are identical.

a = b is not copy, there’re just both refer to the same python object.

  • copy by slicing: a = b[:]
  • use list function: a = list(b)
  • use copy method: a = b.copy()
0%