cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
572
Views
0
Helpful
1
Replies

Python - rstrip

Tim Barlow
Level 1
Level 1

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

 

1 Reply 1

balaji.bandi
Hall of Fame
Hall of Fame

i believe it is match co and com to strip

 

try below snippet :

 

txt = "cisco.com"
bb = txt.split('.')[0]
print(bb)

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help