Representation of phone number in USA format : To string : Class PYTHON TUTORIALS


PYTHON TUTORIALS » Class » To string »

 

Representation of phone number in USA format


class PhoneNumber:
   def __init__self, number ):
      self.areaCode = number1:]
      self.exchange = number6:]
      self.line = number10:14 ]  

   def __str__self ):
      return "(%s) %s-%s" self.areaCode, self.exchange, self.line )

newNumber = "(123) 456-7890"

phone = PhoneNumbernewNumber )  
print "The phone number is:",
print phone



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Class
» To string