0

I am using python 2.7 and here is what I've got.

Method:

def get_phone(self):
    digits = filter(str.isdigit, str(self.phone))
    if re.match(r'(0|380)\d{9}', digits):
        operator = digits[-9:-7]
        digits = digits[-7:]
        return "+380 ({}) {}".format(opeself.rator, digits)
    return None

Now if I use this method like this:

dictionary = {
    'phone': User.get_phone()
} 

the output is:

{'phone': '+380 (12) 1234567'}

But if I use it like so:

dictionary['phone'] = User.get_phone(),

The output becomes a tuple:

{'phone': ('+380 (12) 1234567',)}

What am I doing wrong?

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61

1 Answers1

7

You added a comma here:

dictionary['phone'] = User.get_phone(),

That turns it into a tuple

Johan
  • 477
  • 4
  • 8