Sep-16-2020, 02:43 PM
Hi. I have a problem with code(self studying-just started).
I have a problem "NameError: name 'numb' is not defined".
It should be easy solution for that and im sitting with it about 2 hours.
my code:
I have a problem "NameError: name 'numb' is not defined".
It should be easy solution for that and im sitting with it about 2 hours.
my code:
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 42 43 44 |
from typing import List , Any , TextIO lista: List [ int ] = [] file = str ( input ( "file name: " ) + '.txt' ) n = int ( input ( "give how many digits u want to input, modulo 4 must be 0: \n" , )) while n % 4 ! = 0 : n = int ( input ( "wrong" , )) print ( "give " + str (n) + " digit" ) while len (lista) < n: digit = int ( input ( "give digit: " )) if not 0 < = digit < = 9 : print ( 'wrong' ) else : lista.append(digit) print (lista) m = int ( len (lista) / 4 ) #print(m) for i in range ( 0 , m): x = i y = i + 1 numb.x = int ( str (lista[ 0 + i * 4 ]) + str (lista[ 2 + i * 4 ])) numb.y = int ( str (lista[ 1 + i * 4 ]) + str (lista[ 3 + i * 4 ])) numb.i = (numb.x) + (numb.y) chr (a.i) print ( chr (a.i), end = " " ) file : TextIO = open (( file ), 'w' ) file .write( chr (a.i)) file .close() |