I am new to python programming language, many of my friends told me that Python is a better programming language for beginners. It is easy to pick up. I was convinced by their words and started learning Python. As days are passing I am discovering new things and it keeps attracting me. Well, today I was thinking to write a program that will remove a first character from a string. So I wrote a program below
x = "asdfghjk"
I am wondering is there any other way to achieve this more efficiently!
I have got your issue you to remove the python string datatype of the first characters in the most efficient way first of all if you want we must know that in python string datatype in immutable to any changes is not possible but if we are able to do the some changed you will end up creating the new object of it. and coming to your question if you want to get the first character way is perfect and efficient but if you want to remove it then you can use the slicing below is how can you use it.
strObj = "This is a sample string"
# Slice string to remove first character
strObj = strObj[1 : : ]
print('Modified : ' , strObj)
Modified : his is a sample string
I hope this is going to help you, Happy coding!!