I want to remove a file's last characters that it's name is somedigits plus .py and plus .BR like 0001.py.BR or 0005.py.BR and remove the .BR from the string.
I tried this code
import os
x = input("")
os.rename(x, x[7])
but it sometimes don't work for some file that their names are larger like 00001.py.BR it renames it to 00001.p so is there a way that I just do like this x - ".BR".
os.rename(x, x[:-3])