Lets say i have myVariable = 'Hello world'
How can I get just “World”? Ive tried a bunch of ways. I am trying to make a chat bot at the moment, and I am making a settings command where you type :BotSettings
in a input.
You can split on space and select element nr 1.
myVariable.split(' ')[1]
If I have
myVariable = "Hello World"
, how do I make it "World"?
myVariable = "World"
If I have
myVariable = "Hello World"
, how do I find the second word?
myVariable = myVariable.split()[1] # "World"
If I have
myVariable = "apple Hello World banana"
, how do I find everything written after "Hello"?
_, _, myVariable = myVariable.partition("Hello ")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.