+ 2
I need help with python
I have to do a dice game for course work at school (in python) and using the knowledge of this app i put together the log in section of the game l, but i am unable to find the errors myself, so i was wondering if anyone could help me please. The problem is when i execute the code it allows any username and password to log in. https://code.sololearn.com/cWqDiTY8xddH/?ref=app
7 Answers
+ 4
if str == 'a' or 'b':
is evaluated as
if (str == 'a') or ('b'):
which will always be true.
Instead, do
if str == 'a' or str == 'b':
In the case of your code, change all if statements according to the above fix.
if userinpuse == 'player1' or userinpuse == 'player2':
etc.
+ 3
Mponec
For assignments, use =, and not ==.
username = str(input('Username: '))
etc.
+ 2
Hello Mponec
I see your code is quite big, that's why it didn't fit in Description section. Would you mind saving the code in your profile and share its link instead? remove the code text and put the code link in place of it đ
Here's how to share links just in case you didn't know yet.
https://www.sololearn.com/post/74857/?ref=app
+ 2
userinpus == str('player1') are actually get executed first. then or comes in after the input.
so for example userinpus is 'player'
userinpus == str('player1') or str('player2')
'player' == 'player1' or 'player2'
false or 'player2'
'player2'
+ 1
Mponec
I see you saved the code and share its link.
Thank you for understanding đ
0
Now i am getting no output displayed but it still asks for my inputs, altogh it did say check internet connectin but i have full bars