Skip to content
  • Tutorials
    • c programming
      • libraries
    • c++
    • Linux
    • Python
    • batch programming
    • Technology
  • IDE
  • Tools
add one to all elements in list python 1

add one to all elements in list python

April 26, 2022 by Anurag batra
new_list = [x+1 for x in my_list]

Here is what the above code is Doing:
1. We create a new list called new_list.
2. We iterate through each element in my_list.
3. For each element in my_list, we add 1 to it and append it to new_list.
4. We return new_list.

Categories Python Examples
Post navigation
anaconda create new environment
jupyter notebook delete the output
© MyEduKit - 2022 . All Rights Reserved.