Answers for "remove a character from beginning and end of a string in python"

2

Remove the First Character From the String in Python Using the Slicing

greeting = "HHello world!"
new_greeting = greeting[1:]
# In here we select greeting string from character 1 to end (except character 0)
print(new_greeting)
#output: Hello world!
Posted by: Guest on November-30-2021
1

python remove characters from end of string

foo = "test716"
foo = foo[:-3]
print(foo)
# output will be "test"
Posted by: Guest on August-19-2021

Code answers related to "remove a character from beginning and end of a string in python"

Python Answers by Framework

Browse Popular Code Answers by Language