I need to remove last "1" residing in the URL so that I can implement it in my code. Is there any method in the python to remove that "1"?
Asked
Active
Viewed 46 times
-2
-
2Possible duplicate of [Replace part of a string in Python?](https://stackoverflow.com/questions/10037742/replace-part-of-a-string-in-python) – Georgy Dec 03 '18 at 11:08
-
@Georgy how is it same as I have find all the related questions, studied them and found not a single relavent answer. Then posted the questions. The question you are referring is containing loops. where as my case doesn't need loops – Yawar Abbas Dec 03 '18 at 11:22
1 Answers
2
a= "https://www.amazon.com/I3565-A453BLK-PUS-Dell-Laptop-Dual-Core-Processor/product-reviews/B07BLPHRX9/ref=cm_cr_arp_d_viewopt_srt?ie=UTF8&reviewerType=all_reviews&filterByStar=positive&pageNumber=1&sortBy=recent"
b= a.replace("pageNumber=1","pageNumber=")
print(b)
This is how you can do. Use string.replace() to replace anything in the string.

Pardeep
- 2,153
- 1
- 17
- 37

Nagesh Katna
- 679
- 2
- 7
- 27