Selling and Controlling Stock (Python)

Asked

Viewed 260 times

-1

Give me a break. How do I input the input data to a pre-registered dictionary for the person using the program? Also, it can update the stock data, and automatically discount when the sale is made. I had very few lessons in Python, and this work came up to do. I don’t necessarily want the code ready, but how can I do it. Follow what I’ve managed to do so far: https://pastebin.com/N2bQ7pCq

1 answer

0

How to solve this problem after choosing item 6:

  • List products with an Index;
  • Ask the user to choose an Indice number to change;
  • Check if the chosen id is less than Len(choice) ... if yes, then the option exists;
  • Scroll by Dict() using enumerate() method to get the Dict Input and key();
  • If id to change == Dict() input('new value'); input('new quanti')
  • stock[key] = [nova_quant, new_value]
    def listar():
    print(f'{"Index":<8} {"Produto ":<9}{"":-<20} {"Quantidade":<12} {"Valor"}')
    index = 0
    for key, value in estoque.items():
        print(f'{index:<8} {key:<9}{"":-<20}{"":<3} {value[0]:<9} {value[1]}')
        index += 1
    id_list = []

    def conferir(numero_id):
        for ind, val in enumerate(estoque):
            id_list.append(ind)
        if numero_id in id_list : return True
        else : return

    def editar(id_alterar):
        for indice, nome in enumerate(estoque):
            if indice == id_alterar:
                n_valor = float(input('Digite o novo valor para o produto: '))
                n_quant = int(input('Digite a nova quantidade para o produto: '))
                estoque[nome] = [n_quant, n_valor]
    elif opcao == 6:
    listar()
    alteracao = int(input('Digite o número do do id do produto que deseja alterar: '))
    conf = conferir(alteracao)
    if conf:
        editar(alteracao) 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.