Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to check if a string ends with a substring python

inp = input("Enter file name: ")
if inp.endswith(".py"):
  print("Your file is a python file!")

# There are two examples here
# if the input ends with .py then inp.endswith(".py") will output True
# and prints "Your file is a python file!" in this example
# if it doesnt end with .py then it will output False
 
PREVIOUS NEXT
Tagged: #check #string #ends #substring #python
ADD COMMENT
Topic
Name
7+9 =