human
How to replace (or strip) an extension from a filename in Python?
assistant
Here is some code to replace extension '.txt' in basename '/home/user/somefile.txt' with extension '.jpg'

print(os.path.splitext('/home/user/somefile.txt')[0] + '.jpg')

#Warning: this code generation is experimental. Please inspect the code for any bugs before executing.