Is there an easy way to remove the last character in a string in python

Viewed 32

[The original question] Does not address not when you don't know the postion of that last occurrence 1I want to replace the last occurrence of the "," with a blank, the code below only replaces all the "," in the line variable

def create_payload ():
line =  'post_iceauth_oauth_token_helper, \n'
   
if regex.search(",", line):

        temp = regex.sub(",", "", temp)  # remove the (, )

This is not explaining the last replacement it only speaks of knowing position

0 Answers
Related