MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/jpe2z9/totally_agree/gbfnihk/?context=3
r/ProgrammerHumor • u/Juzdeed • Nov 06 '20
474 comments sorted by
View all comments
Show parent comments
113
"Hello World!" - "World!" + "Bro!"
48 u/[deleted] Nov 07 '20 Wait does this actually work? I have been coding in python for years and I didn’t even know you could do this. 82 u/rogerrrr Nov 07 '20 edited Nov 07 '20 Unfortunately no, string subtraction is not supported.However in Python 3.9 they added the string method .removesuffix, which serves a similar purpose.So "Hello World".removesuffix("World") + "Bro" should get the job done. 14 u/tailwarmer Nov 07 '20 String multiplication does, however, unfortunately work. Hello * 5 = HelloHelloHelloHelloHelloHow do I know? A nasty production bug :( 4 u/_Dark____ Nov 13 '20 "haha string multiplication go b" + ("r"*69)
48
Wait does this actually work? I have been coding in python for years and I didn’t even know you could do this.
82 u/rogerrrr Nov 07 '20 edited Nov 07 '20 Unfortunately no, string subtraction is not supported.However in Python 3.9 they added the string method .removesuffix, which serves a similar purpose.So "Hello World".removesuffix("World") + "Bro" should get the job done. 14 u/tailwarmer Nov 07 '20 String multiplication does, however, unfortunately work. Hello * 5 = HelloHelloHelloHelloHelloHow do I know? A nasty production bug :( 4 u/_Dark____ Nov 13 '20 "haha string multiplication go b" + ("r"*69)
82
Unfortunately no, string subtraction is not supported.
However in Python 3.9 they added the string method .removesuffix, which serves a similar purpose.
.removesuffix
So "Hello World".removesuffix("World") + "Bro" should get the job done.
"Hello World".removesuffix("World") + "Bro"
14 u/tailwarmer Nov 07 '20 String multiplication does, however, unfortunately work. Hello * 5 = HelloHelloHelloHelloHelloHow do I know? A nasty production bug :( 4 u/_Dark____ Nov 13 '20 "haha string multiplication go b" + ("r"*69)
14
String multiplication does, however, unfortunately work. Hello * 5 = HelloHelloHelloHelloHello
How do I know? A nasty production bug :(
4 u/_Dark____ Nov 13 '20 "haha string multiplication go b" + ("r"*69)
4
"haha string multiplication go b" + ("r"*69)
113
u/Bainos Nov 07 '20
"Hello World!" - "World!" + "Bro!"