Why I can't reach else block when there is no rfid mark - Python
gaviria26
6/7/2021, 12:50:56 PM
Ответов:
Why I can't reach else block when there is no rfid mark

in database? Lines 20-21 https://pastebin.com/SagBQpZR

Ответы (35)

King Phyte
6/7/2021, 12:53:56 PM

Try setting a breaking on where the condition is and see what value comes out there

Artem
6/7/2021, 12:54:46 PM

you mean put break in if block?

King Phyte
6/7/2021, 12:55:12 PM

No. Like a debugger breakpoint.

Artem
6/7/2021, 12:55:23 PM

Ah, got you

Артём Юров🇷🇺
6/7/2021, 12:57:08 PM

did you try to pass an obviously Falsy data sample?

King Phyte
6/7/2021, 12:57:17 PM

Yeah. If rfid can be None, resort to using is/is not None to for the condition rather than ==

Artem
6/7/2021, 12:58:18 PM

nah, i didn't

Артём Юров🇷🇺
6/7/2021, 12:58:26 PM

try it :)

Artem
6/7/2021, 1:02:37 PM

elif rfid != '2015rf54': print('There is no such user in database') I tried this, if I got you right. I put some random rfid in there

Артём Юров🇷🇺
6/7/2021, 1:02:59 PM

good. did it work? :)

Artem
6/7/2021, 1:03:07 PM

it didn't

Артём Юров🇷🇺
6/7/2021, 1:03:21 PM

it didn't print right?

Artem
6/7/2021, 1:03:33 PM

yes, no output at all

King Phyte
6/7/2021, 1:04:01 PM

Did you try the debugger?

Артём Юров🇷🇺
6/7/2021, 1:06:19 PM

did I get you right that '2015rf54' is that random thing you put there?

Artem
6/7/2021, 1:06:46 PM

I'm trying to put breakpoint at else statement line and print line also, but debuggers says that there is no such table: users

Artem
6/7/2021, 1:07:06 PM

yes, it is

King Phyte
6/7/2021, 1:08:09 PM

Put it at the if statement

Артём Юров🇷🇺
6/7/2021, 1:08:31 PM

try some debug prints to see the values

Artem
6/7/2021, 1:09:00 PM

I put it, same result

King Phyte
6/7/2021, 1:10:15 PM

Nah.. Don't focus on the result What is the value of rfid and get_response when you evaluate line by line? Are they the same?

Artem
6/7/2021, 1:11:28 PM

8 chars

Artem
6/7/2021, 1:13:15 PM

If rfid is the same as response, I activate a command. But if there is no rfid as response gives me then I need to show output that there is no such user. When I'm scanning rfid that is not in the base, it doesn't show me anything for some reason. Kind of weird.

King Phyte
6/7/2021, 1:14:22 PM

I don't think you get what I mean

Artem
6/7/2021, 1:14:48 PM

both str if you meant that

Артём Юров🇷🇺
6/7/2021, 1:15:05 PM

he meant the actual values

King Phyte
6/7/2021, 1:16:04 PM

I mean use the debugger to step through the code, it'll literally tell you what all the values evaluate to

Artem
6/7/2021, 1:16:12 PM

it looks like this 201e460d, but other chars @King_Phyte

Артём Юров🇷🇺
6/7/2021, 1:16:21 PM

always the same value?

Artem
6/7/2021, 1:16:31 PM

nah, always unique

Артём Юров🇷🇺
6/7/2021, 1:17:00 PM

make a test. Put there one correct value and one incorrect. And run your initial program

Artem
6/7/2021, 1:18:04 PM

Oh, you mean I need to put a correct value to else statement and check the output?

Артём Юров🇷🇺
6/7/2021, 1:18:35 PM

no. put one correct and one incorrect. (I guess there's nothing wrong with your print() right?)

Артём Юров🇷🇺
6/7/2021, 1:19:40 PM

and add sth like print(rfid) inside "else"

Artem
6/7/2021, 1:19:45 PM

yes, its ok. got you

Похожие вопросы по теме Python

Аноним
6/7/2021, 10:44:32 AM
Ответов: 34
I'm trying to build a simple calculator in python using tkinter. After

getting the input stringwith mathematical signs and numbers, is there any function to compute it?

Аноним
8/19/2021, 2:15:37 PM
Ответов: 33
How can I solve ax^2+bx+c<0 in python?
BprMain
1/22/2021, 7:32:55 AM
Ответов: 29
How can I update for my python package?
MRN00P
3/22/2021, 11:08:24 AM
Ответов: 29
Hello, I got this code: for i in range 1000000000, 1299999999:

x = 0 printx,i and I would like to make it print without a space between the x and the i .. what should I do?

Аноним
4/14/2021, 6:35:53 PM
Ответов: 27
Hi, I'm trying to use Pyqt5 to make a GUI. I want

to push a button on it with Right Click of the mouse. I've seen something on Google but I didn't find. How can I do that?

Аноним
10/1/2020, 7:17:56 PM
Ответов: 29
Like what? In the code editor? I dont understand your question
fsdevel
2/3/2021, 8:06:49 PM
Ответов: 30
I have an small storage about 64byte and want to save this

code in it can somebody compact it more? nums = [ input for num in range11 ] printnums[10] in nums[:10]

KING_MS_7
5/3/2021, 5:09:28 PM
Ответов: 27
I want to know what we can do with python?
yashrj25
4/8/2021, 12:07:28 PM
Ответов: 27
How to extract "25APR19" from "ACC25APR191480PE"?
Аноним
1/21/2021, 9:23:21 PM
Ответов: 30
Hi, I'm learning the basics of web scraping and i've done a

script that helps me with be up to date with my school's important information, i would like to receive some feedback so can i share with you the github repository's link?