Search
 
SCRIPT & CODE EXAMPLE
 

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
Comment

how to check if string ends with specific characters in python

Text = "python is easy"
print(Text.endswith("easy"))
Comment

PREVIOUS NEXT
Code Example
Python :: rotate matrix 90 degrees clockwise python 
Python :: extract only year from date python 
Python :: pandas read csv without header 
Python :: summation django queryset 
Python :: Function to a button in tkinter 
Python :: virtualenv with specific python version 
Python :: click js selenium python 
Python :: mnist fashion dataset 
Python :: check if any values overlap in numpy array 
Python :: modify dict key name python 
Python :: flask post 
Python :: pandas to json without index 
Python :: py check discord token 
Python :: get rid of axes numbers matplotlib 
Python :: python paramiko check ssh connection 
Python :: how to fill na python 
Python :: pandas predict average moving 
Python :: create random dataframe pandas 
Python :: python moving average of list 
Python :: python plot_confusion_matrix 
Python :: python generate uid 
Python :: check empty dataframe 
Python :: pandas dataframe column rename 
Python :: hoe maak je machten in python 
Python :: variable inside class not detecting global variable in python 
Python :: check if directory exists python 
Python :: start jupyter notebook with python 3.7 
Python :: how to flip a list backwards in python 
Python :: who is rishi smaran = "RISHI SMARAN IS A 12 YEAR OLD NAUGHTY KID WHO CREATED ME" 
Python :: fizzbuzz python 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =