Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
my list is being changed
#1
Hello guys, here again.
i got a problem i thought would not be possible, i'v created a list for being used as a data base, just for grabbing info, i made it for not being changed , but at a point of my code it just starts to me adulterated, what makes no sense.. here is the code.. its very messy but please go easy on me.. i wanna know what is the problem.. it changes at the second loop when you type 1 instead of 0 when it asks: "continuar?".. well.. the thing is, the list : pedidosafe should not change... ever

please heelp
pedidos = []
dicionario = {}
itens_pedido = []
pedidosafe = []
inicio = 'S'
indic_pedido = 0
while inicio in 'Ss':
    romaneio = int(input('informe o pedido\n:'))
    pedido = open(f'Pedidos_test\{romaneio}.txt', 'r')
    cont_inicio = 0
    for c, linha in enumerate(pedido):
        if linha.rstrip():
            novo = int(linha)
            itens_pedido.append(novo)
    n = romaneio
    p = indic_pedido
    dicionario.update({p:n})
    inicio = str(input('Nova entrada?\n[S/N]:')).upper().strip()
    indic_pedido += 1
    pedidos.append(itens_pedido[:])
    pedidosafe.append(itens_pedido[:])
    itens_pedido.clear()
analise = []
resumo = []
resumobk = []
juntar = []
pedidosbk = []
itendupl = []
tuple(pedidosafe)
#APB = adicionar em pedidos backup
for APB in pedidos:
    pedidosbk.append(APB)
for q in range(0, 6):
    print('chegou?')
    print(f'{pedidosafe}pedidos safe')
    cont = vezes = contador = numlist = posi = ped = trigger = numped = controle = controledoresumo = menu = controle_posi = 0
    if menu == 0:
        print('linha2')
        print(f'{pedidosafe}pedidossafe')
        for general in range(0, 7):
            while trigger == 0:
                print('\033[31m ok triger\033[m')
                for c, p in enumerate(pedidos):
                    for m in p:
                        if cont == 0:
                            print('\033[31m ok if cont == 0\033[m')
                            analise.append(m)
                        if cont >= 1:
                            print('\033[31m ok if cont >= 1\033[m')
                            contador += 1
                            if m in analise:
                                print('\033[31m ok m in analise\033[m')
                                vezes += 1
                            if len(p) == contador:
                                print('\033[31m ok len(p) == contador\033[m')
                                resumo.append([c + controle])
                                resumo[posi].append(vezes)
                                vezes = 0
                                contador = 0
                                posi += 1
                    if c == len(pedidos)-1:
                        print('\033[31m ok c == len(pedidos)\033[m')
                        for posiped in resumo:
                           posiped.insert(0, ped)
                        del(pedidos[0])
                        ped += 1
                    cont += 1
                controle += 1
                controledoresumo += 1
                if controledoresumo <= 8:
                    print('\033[31m ok controledoresumo <=8\033[m')
                    resumobk.append(resumo[:])
                    resumo.clear()
                    cont = vezes = contador = posi = 0
                    if len(pedidos) == 0:
                        print('\033[31m ok len(pedidos) == 0\033[m')
                        trigger = 1
                        resumobk.pop()
                    posi = 0
                resumo.clear()
                analise.clear()
            pedido1 = 0
            pedido2 = 0
            mai = cont2 = 0
            for r in resumobk:
                for v in r:
                    if cont2 == 0:
                        print('\033[31m ok cont2 == 0\033[m')
                        mai = v[2]
                        pedido1 = v[0]
                        pedido2 = v[1]
                    if cont2 >= 1:
                        print('\033[31m ok cont2 >= 1\033[m')
                        if v[2] >= mai:
                            mai = v[2]
                            pedido1 = v[0]
                            pedido2 = v[1]
                    cont2 += 1
            print(f'{pedidosbk}este é o pedidobak original')
            print(f'{pedidosafe}pedidosafe')
            for insert in pedidosbk:
                pedidos.append(insert)
                print(f'{pedidos}adicionando pedidosbk no pedidos')
                print(f'{pedidosafe}pedidosafe ponto')
            primeirasom = list(set(pedidosbk[pedido1]+pedidosbk[pedido2]))
            tuple(pedidosafe)
            pedidos[pedido1] = primeirasom
            pedidos[pedido2].clear()
            juntar.append(pedido1)
            juntar.append(pedido2)
            print(f'{pedidosafe}pedidosafedenovo')
            trigger = 0
            cont2 = 0
            pedido1 = 0
            pedido2 = 0
            controle = 0
            ped = 0
            pedidosbk.clear()
            for insert2 in pedidos:
                pedidosbk.append(insert2)
            print('essa linha?')
            print(f'{pedidos}este é pedidos apos ser inferido')
            if len(set(juntar)) >= 6:
                for dic in set(juntar):
                    print(dicionario[dic])
                print(f'{pedidos}pedidos')
                print(f'{pedidosbk}pedidosbk')
                print(f'{pedidosafe}pesdidossafe')
                for additen in pedidosafe:
                    print(f'{juntar} este é juntar')
                    print(f'{controle_posi} este é o controle da posição atual')
                    print(f'{itendupl}itemdup')
                    if controle_posi in set(juntar):
                        print('\033[31m ok in set(juntar)\033[m')
                        for oiten in additen:
                            itendupl.append(oiten)
                    controle_posi += 1
                divisor = len(itendupl)
                dividendo = len(set(itendupl))
                print(f'{divisor},{dividendo}divisor dividendo')
                print(f'{itendupl} agora com len {set(itendupl)}')
                print(f'{abs(float((dividendo / divisor) * 100 - 100)):.0f} % de redução')
            menu = int(input('continuar?'))
            print(f'{pedidosafe}pedidosafe')
            print(set(juntar))
            controledoresumo = 0
            resumobk.clear()
            print(f'{general}este é o contador general')
            print(f'{pedidos}pedidos')
            print(f'{pedidosbk}pedidosbk')
            if menu != 0:
                print('\033[31m ok \033[m')
                itendupl.clear()
                controle_posi = 0
                pedidos.clear()
                pedidosbk.clear()
                itendupl.clear()
                juntar.clear()
                for restart in pedidosafe:
                    pedidos.append(restart)
                    pedidosbk.append(restart)
                menu = 0
                break
Reply


Messages In This Thread
my list is being changed - by ivinjjunior - May-27-2019, 09:55 PM
RE: my list is being changed - by Yoriz - May-27-2019, 11:14 PM
RE: my list is being changed - by ivinjjunior - May-27-2019, 11:21 PM
RE: my list is being changed - by Yoriz - May-27-2019, 11:37 PM
RE: my list is being changed - by ivinjjunior - May-28-2019, 03:27 PM
RE: my list is being changed - by Yoriz - May-28-2019, 07:23 PM
RE: my list is being changed - by ivinjjunior - May-28-2019, 07:47 PM
RE: my list is being changed - by Yoriz - May-28-2019, 08:02 PM
RE: my list is being changed - by ivinjjunior - May-28-2019, 08:07 PM
RE: my list is being changed - by Yoriz - May-28-2019, 08:27 PM
RE: my list is being changed - by ivinjjunior - May-28-2019, 08:30 PM
RE: my list is being changed - by Yoriz - May-28-2019, 08:43 PM
RE: my list is being changed - by ivinjjunior - May-28-2019, 08:56 PM
RE: my list is being changed - by Yoriz - May-28-2019, 09:30 PM
RE: my list is being changed - by ivinjjunior - May-28-2019, 09:43 PM
RE: my list is being changed - by ivinjjunior - May-29-2019, 02:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  The behavior of tune model has changed Led_Zeppelin 5 4,506 Oct-21-2021, 06:52 PM
Last Post: jefsummers
  how can a variable change if I haven't changed it? niminim 5 3,132 Apr-07-2021, 06:57 PM
Last Post: niminim
  RuntimeError: dictionary changed size during iteration Shreeniket987 3 3,783 Jun-01-2019, 01:22 PM
Last Post: buran
  RuntimeError: dictionary changed size during iteration anna 4 3,548 Feb-20-2019, 11:04 AM
Last Post: anna
  how to work with variables changed in definitions Prof_Jar_Jar 2 2,639 Dec-16-2018, 12:04 AM
Last Post: Prof_Jar_Jar
  RuntimeError: dictionary changed size during iteration Skaperen 1 9,172 Dec-10-2018, 10:14 PM
Last Post: nilamo
  Saving Values Changed in a database themick789 1 2,298 Nov-28-2018, 08:16 AM
Last Post: Larz60+
  Strange the name of the file is changed automaticaly sylas 3 3,232 Jun-05-2018, 06:43 PM
Last Post: buran
  How can I use GNU readline when the value of sys.stdin has been changed? thePhysicist8 6 7,157 Dec-30-2016, 10:09 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020