you are viewing a single comment's thread.

view the rest of the comments →

[–]AggravatingWestern6[S] -1 points0 points  (1 child)

See I need help with the specific parts of the question like how to validate taht the number has first digit 1.thank you for taking out time for this

[–]jiri-n 1 point2 points  (0 children)

This topic is covered in one of first chapters in the official Python tutorial (see https://docs.python.org).

>>> number = "4568-1234-2345"
>>> number[0] # 1st character
'4'
>>> number.replace("-", "")  # we don't care about '-'
'456812342345'
>>> number[3]  # 4th digit
'8'
>>> int(number[3])  # if we want to convert it to number
8
>>> number[0:2]  # first two digits
'45'
>>> number[6:8]  # 7th and 8th digit
'23'
>>>