-3

For the following code,

import re
n = '.172..16.52.207,172.16.52.117'
s = re.split(',+|\.+',n)
print s

why is the first element of s a blank, i.e. '' ?

the_storyteller
  • 2,095
  • 26
  • 34

1 Answers1

0

The first element is everything between the beginning of the string and the first .. There are no such characters, so it is ''. n[2] should be blank as well, because there is nothing between the second . and the third.

the_storyteller
  • 2,095
  • 26
  • 34
Acccumulation
  • 3,215
  • 1
  • 6
  • 11