I have used the following method to delete a certain trailing string of characters 'lbs' from a string of characters. But, when I run my code and print out the result nothing is changed and the string of characters hasn't been eliminated. Would appreciate your help in this situation! Thanks for the help!
Data:
**Weights:**
0 159lbs
1 183lbs
2 150lbs
3 168lbs
4 154lbs
**Code:**
# Converting the Weights to an Integer Value from a String
for x in Weights:
if (type(x) == str):
x.strip('lbs')
**Output:**
Weights:
0 159lbs
1 183lbs
2 150lbs
3 168lbs
4 154lbs
x.strip('lbs')generated a new string, with the indicated letters removed from the ends. However, this accomplished absolutely nothing, as you didn't do anything with the new string.