Menu

Sign in to track your progress and unlock all features.

Theme style

Log in

Full lesson preview

Increment a Number

Use augmented assignment to increment a numeric value by a given amount.

Python practice10 minVariables & Data TypesBeginnerLast updated December 29, 2025

Problem statement

Implement increment(n, amount=1) that increases n by amount using augmented assignment (n += amount) and returns the new value. The default increment amount is 1.

Task

Practice using the += operator to update a variable and return the result.

Examples

Increment by 1

Input

increment(3)

Output

4

Default amount is 1, so 3 becomes 4.

Input format

A function call increment(n, amount) where n and amount are numbers. amount is optional and defaults to 1.

Output format

Return the updated numeric value after incrementing.

Constraints

n and amount will be integers (can be negative or zero). Use augmented assignment (+=) inside the function.

Samples

Sample 1

Input

increment(10, 5)

Output

15

10 incremented by 5 equals 15.