C
C
Cesar12018-05-08 19:23:52
Python
Cesar1, 2018-05-08 19:23:52

How to split text?

The user enters a command, for example 'make.dir' and you want the a variable to be equal to the text before the dot, and b after the dot.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2018-05-08
@Cesar1

a, b = input().split('.')

T
Timebird, 2018-05-09
@Timebird

A more noobish version:

cmd = 'make.dir'
a = cmd.split('.')[0]
b = cmd.split('.')[1]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question