String Ends With in Python

Level 134 keystrokes

This checks if a string ends with a suffix. The endswith() method returns True or False.

Python code

# endswith() returns True if the string ends with the given suffix, otherwise False
# "file.txt" ends with ".txt", so True is printed
1print("file.txt".endswith(".txt"))

Output

True
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this Python code and how often they appear.

  • "× 4
  • .× 3
  • (× 2
  • )× 2

More Python examples at level 1

← Python typing practice