It is a challenge record of Language processing 100 knock 2015. Please see the list from here.
I have only asked one question yet, but I decided to change the environment a little.
Ubuntu has been updated to the latest 16.04 LTS at the moment. Python and gedit are included as standard with this Ubuntu.
My computer is Mac mini (Late 2012), and I use Parallels Desktop 12 to virtualize Ubuntu. The procedure for installing Ubuntu is I am using Ubuntu 16.04 LTS with Parallels Desktop 12 ), So if you are interested, please.
Take out the 1st, 3rd, 5th, and 7th characters of the character string "Patatokukashi" and get the concatenated character string.
The finished code:
main.py
# coding: utf-8
target = u'Patatoku Kashii'
result = target[::2]
print(result)
Execution result:
Terminal
Police car
Like last time, I used the slice specified by [start: stop: step]
. Since all are targeted, start and stop are omitted.
You can also take a taxi by setting start to 1 (= 2nd character).
Interpreter
>>> target = u'Patatoku Kashii'
>>> print(target[1::2])
taxi
That's all for the second knock. If you have any mistakes, I would appreciate it if you could point them out.
Recommended Posts