K
K
kgaudium2018-09-30 23:54:11
Python
kgaudium, 2018-09-30 23:54:11

How to do first characters check in python?

How to check the first characters (in this case, 8)? It is necessary that the program determines whether there are these eight characters at the beginning of the variable.
PS I'm null in a for loop

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor Statkevich, 2018-10-01
@kgaudium

or a line cut

a = 'hello world'
print(a[:8])

hello wo

P
planc, 2018-09-30
@planc

a = 'hello world'
a.startswith('hello')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question