I’m currently in the process of developing a tennis-counting system for fun. Since I’m a newby in Python, I’m currently struggling with some parts of the code.
I’m trying compare the amounts of sets that a player (or both) played to the total amount of sets you can play.
Here’s part of my code:
def set():
global listenpunkteone
global listenpunktetwo
global setlisteone
global setcounter
global scoreone
global scoretwo
if setlisteone[setcounter] < 6 and setlistetwo[setcounter] < 6:
if scoreone == 50:
scoreone = 0
listenpunkteone += 1
setlisteone[setcounter] = listenpunkteone
print("The score is",setlisteone[setcounter],":", setlistetwo[setcounter])
game()
elif scoretwo == 50:
scoretwo = 0
listenpunktetwo += 1
setlistetwo[setcounter] = listenpunktetwo
print("The score is",setlisteone[setcounter],":", setlistetwo[setcounter])
game()
elif setlistetwo[setcounter] == 6:
setlistetwo[setcounter] = listenpunktetwo
print("The score is",setlisteone[setcounter],":", setlistetwo[setcounter])
listenpunktetwo = 0
setcounter += 1
setlistetwo[setcounter] = setlistetwo.append(listenpunktetwo)
game()
elif setlisteone[setcounter] == 6:
setlisteone[setcounter] = listenpunkteone
print("The score is",setlisteone[setcounter],":", setlistetwo[setcounter])
listenpunkteone = 0
setcounter += 1
setlisteone[setcounter] = setlisteone.append(listenpunkteone)
game()
setcounter is supposed to go up by 1 any time that a set has been played (surpassing of 40 points) – it does so nicely up until the score is e.g. 6:0. After, the code just breaks and gives me the Error:
TypeError: ‘<‘ not supported between instances of ‘NoneType’ and ‘int’
Is there any other way for me to compare the specific value of a list element to an integer of my choosing?
Also I don’t understand why my code runs smoothly up until hitting 6:0 -> shouldn’t a new element be automatically be appended after reaching 6 and the process repeated?
Thank You in Advance!
Ginger is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.