How to Search and Modify Lists in Python - #First steps in Python part 7
Today I learned a bit of Python, and how I can modify lists in my code!
The ideia is modifying my lists and variables while the code is running, and not manually , so here is an exemple:
PriceLowering=input("\nType the Name of the product that must have a lower price : ")
for Product in inventory:
if PriceLowering==Product[0]:
print("Old Price: ", Product[1])
Product[1] = Product[1] * 0.9
print("New Price: ", Product[1])
in this short code, I take a List and modify one of it's contents that I myself define, and then make it's price 10% lower by multiplying it by 0.9.
This is used everywhere since things are constantly changing, and having the ability to change that just by typing it, instead of needing to stop, find the variable where the contents are, change it, and run the code again.
The course I am using(it's in Portuguese): https://on.fiap.com.br/local/salavirtual/conteudo-digital.php
If you have any question or suggestion on other topics, feel free to comment down below or ask me in Facebook or Instagram!
Visit my Facebook Page in: http://fb.com/teteusbionicoficial
Visit my Instagram: https://www.instagram.com/teteusbionic/
Visit my Website: http://www.teteusbionic.com.br