598
Views
0
Helpful
1
Replies
Python - rstrip
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2022 09:13 AM
I was doing the Cisco Python Essentials training and I noticed an oddity with rstrip:
print("cisco.com".rstrip("com")) produces "cisco." as would be expected
but:
print("cisco.com".rstrip(".com")) produces "cis" not "cisco" as I was expecting.
Why is this?
Thanks
Labels:
- Labels:
-
Technical Documentation
1 Reply 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2022 09:40 AM
i believe it is match co and com to strip
try below snippet :
txt = "cisco.com"
bb = txt.split('.')[0]
print(bb)
