-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPymachine_code.py
More file actions
41 lines (30 loc) · 1.24 KB
/
Pymachine_code.py
File metadata and controls
41 lines (30 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
shops = ['Iphone', 'Desktop', 'Headset'] # uma lista para os produtos
prices = [2500, 3200, 175] # e uma lista para os valores
cod = 1384 #o código da empresa
print('--- PRODUCTS AVAILABLE ---')
for item in shops: # (for item) refere-se aos itens da primeira lista (shops), podendo ser outras coisas também.
print(item)
print()
product = input('What do you want to buy? ').capitalize()
if product in shops:
index = shops.index(product)
price = prices[index]
print(f'{product} value: {price} R$')
print('\n*** PAYMENT METHODS BELOW ***')
print('Credit card')
print('Paypal')
payment = input('Choose the payment method: ').capitalize()
if payment == 'Credit card':
card = int(input('Enter your credit card number: '))
print(f'\n✅ Successful payment! Enjoy your new {product}.')
elif payment == 'Paypal':
code = int(input('Enter our code: '))
value = float(input('Enter the value: '))
if code == cod and value == price:
print(f'\n✅ Successful payment! Enjoy your new {product}.')
else:
print('\n❌ Payment failed. Incorrect code or amount.')
else:
print('\n⚠️ Invalid payment method.')
else:
print('\n❌ Product not found.')