Skip to content
CodeAllow
  • Calculators
  • Pandas
  • Seaborn
  • NumPy
  • Tkinter
  • Python Basics
    • List
    • String
    • Python datetime
  • Toggle website search
Menu Close
  • Calculators
  • Pandas
  • Seaborn
  • NumPy
  • Tkinter
  • Python Basics
    • List
    • String
    • Python datetime
  • Toggle website search

Add a Number to a List in Python

  • Post published:May 23, 2023
  • Post category:List

Adding a number to a list in Python can be done using the append() method or the + operator. Here are two examples:

Example 1:

numbers = [1, 2, 3, 4, 5]
numbers.append(6)
print(numbers)

Output:

[1, 2, 3, 4, 5, 6]

Example 2:

numbers = [1, 2, 3, 4, 5]
numbers = numbers + [6]
print(numbers)

Output:

[1, 2, 3, 4, 5, 6]

Read more articles

Previous PostSwap Elements in a List in Python
Next PostPrint Index and Value of List in Python

You Might Also Like

Multiply All Elements of a List in Python

May 23, 2023

Find the Index of All Occurrences in a List in Python

May 19, 2023

Check if an Element Exists in a List in Python

May 19, 2023

Relevant Posts

  • Standard Deviation Calculator
  • List Comprehension in Python
  • List Index Out of Range in Python
  • Get Unique Values in a List in Python
  • Subtract Two Lists in Python
  • Find the Maximum Value in a List in Python
  • Convert a List to JSON in Python
  • Create a List of Zeros in Python
  • Multiply All Elements of a List in Python
  • Apply the Map Function to a List in Python
  • Find the Intersection of Two Lists in Python
  • Make a Copy of a List in Python
  • Find the Difference Between Two Lists in Python
  • Convert a List to CSV in Python
  • Find the Mean of a List in Python
  • Reverse a List in Python
  • Find the Average of a List in Python
  • Delete a List in Python
  • Iterate Through Two Lists in Parallel in Python
  • Count the Occurrence of an Item in a List in Python
  • Privacy Policy
  • About
  • Contact Us
  • Disclaimer for Code Allow
  • Terms and Conditions
@2024 - CodeAllow