F
F
FinnJI2018-10-09 19:50:02
Python
FinnJI, 2018-10-09 19:50:02

How to split input data into variables?

I need to make the program understand commands, that is: if I enter "search for 15" for example , then a='search' and b='15' It is also desirable that the program understand commands such as 'add to hs' 15' in which case the variables would be a ='add to hs' and b='15'

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
longclaps, 2018-10-09
@FinnJI

a, b = 'добавить в чс 15'.rsplit(maxsplit=1)
Read the docs .

I
Igor Statkevich, 2018-10-10
@MadInc

depending on where to enter if you run from the command line, then it may make sense to get confused with sys.argv

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question