+ 3

QR Code // SOLVED

Hey guys, what do you think about this code?. https://code.sololearn.com/cHpCMqh3PzE9/?ref=app

10th Jan 2020, 5:06 AM
el3be
el3be - avatar
8 Respuestas
+ 1
In your original code you get NameError because crearQR does not have access to the local variable you define in the other function. Therefore the best way is to pass it as parameter!
10th Jan 2020, 5:51 AM
Tibor Santa
Tibor Santa - avatar
+ 1
Looks like a nice little console application, you have functions with clear purpose, you have error handling.. I would probably pass the url (codigo variable) as parameter to the crearQR function, because it is in the local scope of the other function. Do you have any specific questions?
10th Jan 2020, 5:30 AM
Tibor Santa
Tibor Santa - avatar
+ 1
Thank you friend!!
10th Jan 2020, 3:14 PM
el3be
el3be - avatar
0
To define the variable código with str input, redirects me to the exception ( line 36 )
10th Jan 2020, 5:45 AM
el3be
el3be - avatar
0
These are the changes I propose, the rest looks ok def crearQR(codigo): qrcode.make(codigo) ... def definicion(): ... crearQR(codigo)
10th Jan 2020, 5:49 AM
Tibor Santa
Tibor Santa - avatar
0
Tibor Santa can you solve my code?
10th Jan 2020, 4:30 PM
el3be
el3be - avatar
0
Solve? What do you mean? I gave you the fix didn't I?
10th Jan 2020, 4:35 PM
Tibor Santa
Tibor Santa - avatar
0
Tibor Santa no, I mean that if You can solve the error that you say, because I pass the variable as parameter but another error appears.
10th Jan 2020, 5:58 PM
el3be
el3be - avatar