Browse Source

Fixed formatting error in get_product_information. Got rid of a comparison to None.

Jonathan Reem 12 năm trước cách đây
mục cha
commit
4050238bf3
1 tập tin đã thay đổi với 4 bổ sung4 xóa
  1. 4 4
      3-tier.py

+ 4 - 4
3-tier.py

@@ -35,13 +35,13 @@ class Ui(object):
 
     def get_product_information(self, product):
         product_info = self.business_logic.product_information(product)
-        if product_info is not None:
+        if product_info:
             print('PRODUCT INFORMATION:')
-            print('Name: {:.s}, Price: {:.2f}, Quantity: {:.d}'.format(
+            print('Name: {0}, Price: {1:.2f}, Quantity: {2:}'.format(
                    product.title(), product_info.get('price', 0),
-                   product_info.get('quantity', 0))
+                   product_info.get('quantity', 0)))
         else:
-            print('That product "%s" does not exist in the records' % product)
+            print('That product "{0}" does not exist in the records'.format(product))
 
 
 if __name__ == '__main__':