Oct-22-2018, 01:43 PM
Not bad. A few tips/pointers:
I would put the items in a dictionary. Have the items be keys and the costs be values (as integers). I would think the system would tell you the cost of the thing you purchased. Currently your system allows buying a laptop for 1200.
I don't understand the format on the user_2 input. Why format a string literal with another string literal? Unless you're thinking of expanding to other currencies, put Rs in the first string. Also, I would make the names user_1 and user_2 more descriptive, like user_item and user_cost. It makes your code easier to read.
The in operator and the lower method of strings would greatly simplify your conditionals. Take this line:
Keep at it.
I would put the items in a dictionary. Have the items be keys and the costs be values (as integers). I would think the system would tell you the cost of the thing you purchased. Currently your system allows buying a laptop for 1200.
I don't understand the format on the user_2 input. Why format a string literal with another string literal? Unless you're thinking of expanding to other currencies, put Rs in the first string. Also, I would make the names user_1 and user_2 more descriptive, like user_item and user_cost. It makes your code easier to read.
The in operator and the lower method of strings would greatly simplify your conditionals. Take this line:
while choice == 'n' or choice == 'no' or choice == 'NO' or choice == 'N':That could be rewritten as:
while choice.lower() in ('n', 'no'):Now you have all four possibilities taken care of with one operator.
Keep at it.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures