D
D
Dmitry Khakrin2021-09-18 11:44:28
Python
Dmitry Khakrin, 2021-09-18 11:44:28

The user enters data, how to separate them according to a certain attribute?

I'm studying regular expressions, but I can't figure out how to format the algorithm, For example, the user enters $ Car DS53F5 in the line,
how to split the lines so that the program outputs as a result:
Name: Car
Code: DS53F5

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FOUREX, 2021-09-18
@degrater

At least like this:

inp = input("Введите товар: ")

name = inp.split()[0]
code = inp.split()[1]

print(f'Наименование: {name}\nКод: {code}')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question