mercredi 21 juillet 2021

for and if statement with variables

Dears,

I'm on writing a code which trait str, we have as data input :

  • Module list: it's a list of modules with their position and their value (stocked on Excel file ) Example :

            |module|position|value|
            |LL700 |   1    |  1  |
            |LL701 |   2    |  1  |
    
  • code str : Example >> (1X1XX1111211XXXXX1XX1XXXXXX1XX4XX12XXXXXX1X1XXXX1XXX1X11XXXXXX1X1X9XX1XXXXXXXX)

following the example above, We have a value 1 in the first position its means LL700 is included in that's code this is my try :

Modulecode = part[Vin1+1:option1]
Cnum=len(Modulecode) # 

print(Modulecode)#str code which need to trait
modlist=500
i=1
j=1

Vinnumber=part[win1+1:wiv1]

print(Vinnumber)

ss=modullist.cell(1,1).value
print(ss)

for i in range(Cnum):
    for j in range(modlist):
        mul=modullist.cell(j,2).value
        mlist=modullist.cell(j,3).value
        if mul ==i and mlist== Modulecode[i]:
            print('LL700') 

Error:

runfile('C:/Users/Elkassah/Desktop/untitled2.py', wdir='C:/Users/Elkassah/Desktop')
1X1XX1111211XXXXX1XX1XXXXXX1XX4XX12XXXXXX1X1XXXX1XXX1X11XXXXXX1X1X9XX1XXXXXXXXX
MA45060
Modul
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\Elkassah\anaconda3\lib\tkinter\__init__.py", line 1883, in __call__
    return self.func(*args)
  File "C:\Users\Elkassah\Desktop\untitled2.py", line 141, in func
    mm=modullist.cell(j,2).value
  File "C:\Users\Elkassah\anaconda3\lib\site-packages\openpyxl\worksheet\worksheet.py", line 238, in cell
    raise ValueError("Row or column values must be at least 1")
ValueError: Row or column values must be at least 1
Traceback (most recent call last):

  File "C:\Users\Elkassah\Desktop\untitled2.py", line 209, in <module>
    window.mainloop()

  File "C:\Users\Elkassah\anaconda3\lib\tkinter\__init__.py", line 1420, in mainloop
    self.tk.mainloop(n)

KeyboardInterrupt
 

Thank you in advance!

Aucun commentaire:

Enregistrer un commentaire