Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello, I suppose there are a lot of mistakes in this code but i don't know where to start
It says at first that in the line 7 there is a syntax error (cannot assign operator)
I also suppose there is a way for making the double zero possible. And I suppose after that mistake I'll have a lot more.
Python
ms_black = int(input("Enter the time the black player thought (in ms): "))
ms_white = int(input("Enter the time the white player thought (in ms): "))


seconds_black = ms_black/1000
if seconds_black > 59:
    minutes_black = (seconds_black-59)/60 and seconds_black_in_clock = 59
else:
    minutes_black_in_clock = 00 and seconds_black_in_clock = seconds_black

if minutes_black > 59:
    hours_black = (minutes_black-59)/60 and minutes_black_in_clock = 59
else:
    hours_black = 00 and minutes_black_in_clock = minutes_black

seconds_white = ms_white / 1000
if seconds_white > 59:
    minutes_white = (seconds_white - 59) / 60 and seconds_white_in_clock = 59
else:
    minutes_white_in_clock = 00 and seconds_white_in_clock = seconds_white

if minutes_white > 59:
    hours_white = (minutes_white - 59) / 60 and minutes_white_in_clock = 59
else:
    hours_white = 00 and minutes_white_in_clock = minutes_white

if ms_black > ms_white:
    print("The time the human player has spent thinking is: %d:%d:%d" %(hours_black, minutes_black_in_clock, seconds_black_in_clock))
else: print("The time the human player has spent thinking is: %d:%d:%d" %(hours_white, minutes_white_in_clock, seconds_white_in_clock


What I have tried:

I don't know what else to do. I should be doing this with only booleans as I only learned that in the course so far.
Posted
Updated 9-Jun-21 6:10am
v2
Comments
Teko JR 9-Jun-21 13:12pm    
Have solved that part. Now I have a problem defining the variables.
Richard MacCutchan 9-Jun-21 16:12pm    
Then please show us the code, and any error messages and explain where the problem occurs. Please do not think that we can magically guess what you are doing.

Python
minutes_black = (seconds_black-59)/60 and seconds_black_in_clock = 59

That line is not valid; the expression "and seconds_black_in_clock = 59" is meaningless in that context. And given that you have similar statements in the remainder of the code, I suggest you delete all of this and start again.

Go to The Python Tutorial — Python 3.7.10 documentation[^] to learn the language.
 
Share this answer
 
To add to what Richard says, "=" is a Python assignment operator:
Python
a = b
Means "assign the value of b to a
The equality comparison operator is "==":
Python
a == b
Means "compare a and b, return true only if they are the same".
"and" is a logical operator:
Python
a and b
Menas compare a and b and return true only if both are true.
Python Comparison Operators[^]
Python Logical Operators[^]

Quite what you meant to do with that code, I'm really not sure...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900