I'm a beginner in programming.
So I'm creating a program that calculates car strength for a racing game, based on a custom rating system that I created.
Now, I'm trying to assign a random number between the values of 1 and 4 to a variable called "RANDOM_PART_OF_DOMINANCE". But when I run the program I'm getting an error that says "invalid syntax" for the "RANDOM_PART_OF_DOMINANCE".
During this section of the program, I am using a multi-way if statement.
The code is right below:
# This is where the user fills in what the "DOMINANCE" is.
dominance = ( int ( input ( "Enter how dominant this car is. What that means is this is how often this car leads laps and win races, compared to what is expected of a car running in that position. This value must be 1 through 8. The former is the lowest value possiblle: " ) )
# Does random test to see if lower or higher dominance rank is selected.
# If "RANDOM_PART_OF_DOMINANCE" selects 1-3, then you get the lower value. If it selects 4 it gets the higher value.
RANDOM_PART_OF_DOMINANCE = random.randint( 1,4 )
# "RANDOM_PART_OF_DOMINANCE_2" is used if and only if "dominance" equals a value that will end up with a ".5". For more info check the docstring on this program.
RANDOM_PART_OF_DOMINANCE_2 = random.randint( 1,2 )
if dominance != " ":
print ( "Please enter a whole number numeric value between 1 and 8." )
dominance = ( int ( input ( "Enter how dominant this car is. What that means is this is how often this car leads laps and win races, compared to what is expected of a car running in that position. This value must be 1 through 8. The former is the lowest value possiblle: " ) )
elif dominance < 1 or dominance > 8:
print ( "Please enter a number between 1 and 8." )
dominance = ( int ( input ( "Enter how dominant this car is. What that means is this is how often this car leads laps and win races, compared to what is expected of a car running in that position. This value must be 1 through 8. The former is the lowest value possiblle: " ) )
elif dominance == str ( dominance ) or dominance == float ( dominance ):
print ( "Please enter a whole number." )
dominance = ( int ( input ( "Enter how dominant this car is. What that means is this is how often this car leads laps and win races, compared to what is expected of a car running in that position. This value must be 1 through 8. The former is the lowest value possiblle: " ) )
elif dominance == 8 and RANDOM_PART_OF_DOMINANCE == 1 or RANDOM_PART_OF_DOMINANCE == 2 or RANDOM_PART_OF_DOMINANCE == 3 and RANDOM_PART_OF_DOMINANCE_2 == 1:
aggression[ 0 ] -= 4
aggression[ 1 ] -= 4
elif dominance == 8 and RANDOM_PART_OF_DOMINANCE == 1 or RANDOM_PART_OF_DOMINANCE == 2 or RANDOM_PART_OF_DOMINANCE == 3 and RANDOM_PART_OF_DOMINANCE_2 == 2:
aggression[ 0 ] -= 5
aggression[ 1 ] -= 5
elif dominance == 8 and RANDOM_PART_OF_DOMINANCE == 4 and RANDOM_PART_OF_DOMINANCE_2 == 1:
aggression[ 0 ] += 13
aggression[ 1 ] += 13
elif dominance == 8 and RANDOM_PART_OF_DOMINANCE == 4 and RANDOM_PART_OF_DOMINANCE_2 == 2:
aggression[ 0 ] += 14
aggression[ 1 ] += 14
elif dominance == 7 and RANDOM_PART_OF_DOMINANCE == 1 or RANDOM_PART_OF_DOMINANCE == 2 or RANDOM_PART_OF_DOMINANCE == 3:
aggression[ 0 ] -= 4
aggression[ 1 ] -= 4
elif dominance == 7 and RANDOM_PART_OF_DOMINANCE == 4:
aggression[ 0 ] += 12
aggression[ 1 ] += 12
elif dominance == 6 and RANDOM_PART_OF_DOMINANCE == 1 or RANDOM_PART_OF_DOMINANCE == 2 or RANDOM_PART_OF_DOINANCE == 3 and RANDOM_PART_OF_DOMINANCE_2 == 1:
aggression[ 0 ] -= 3
aggression[ 1 ] -= 3
elif dominance == 6 and RANDOM_PART_OF_DOMINANCE == 1 or RANDOM_PART_OF_DOMINANCE == 2 or RANDOM_PART_OF_DOMINANCE == 3 and RANDOM_PART_OF_DOMINANCE_2 == 2:
aggression[ 0 ] -= 4
aggression[ 1 ] -= 4
elif dominance == 6 and RANDOM_PART_OF_DOMINANCE == 4 and RANDOM_PART_OF_DOMINANCE_2 == 1:
aggression[ 0 ] += 10
aggression[ 1 ] += 10
elif dominance == 6 and RANDOM_PART_OF_DOMINANCE == 4 and RANDOM_PART_OF_DOMINANCE_2 == 2:
aggression[ 0 ] += 11
aggression[ 1 ] += 11
elif dominance == 5 and RANDOM_PART_OF_DOMINANCE == 1 or RANDOM_PART_OF_DOMINANCE == 2 or RANDOM_PART_OF_DOMINANCE == 3:
aggression[ 0 ] -= 3
aggression[ 1 ] -= 3
elif dominance == 5 and RANDOM_PART_OF_DOMINANCE == 4:
aggression[ 0 ] += 9
aggression[ 1 ] += 9
elif dominance == 4 and RANDOM_PART_OF_DOMINANCE == 1 or RANDOM_PART_OF_DOMINANCE == 2 or RANDOM_PART_OF_DOMINANCE == 3 and RANDOM_PART_OF_DOMINANCE_2 == 1:
aggression[ 0 ] -= 2
aggression[ 1 ] -= 2
elif dominance == 4 and RANDOM_PART_OF_DOMINANCE == 4 and RANDOM_PART_OF_DOMINANCE == 1:
aggression[ 0 ] += 7
aggression[ 1 ] += 7
elif dominance == 4 and RANDOM_PART_OF_DOMINANCE == 4 and RANDOM_PART_OF_DOMINANCE == 2:
aggression[ 0 ] += 8
aggression[ 1 ] += 8
elif dominance == 3 and RANDOM_PART_OF_DOMINANCE == 1 or RANDOM_PART_OF_DOMINANCE == 2 or RANDOM_PART_OF_DOMINANCE == 3:
aggression[ 0 ] -= 2
aggression[ 1 ] -= 2
elif dominance == 3 and RANDOM_PART_OF_DOMINANCE == 4:
aggression[ 0 ] += 6
aggression[ 1 ] += 6
elif dominance == 2 and RANDOM_PART_OF_DOMINANCE == 1 or RANDOM_PART_OF_DOMINANCE == 2 or RANDOM_PART_OF_DOMINANCE == 3 and RANDOM_PART_OF_DOMINANCE_2 == 1:
aggression[ 0 ] -= 1
aggression[ 1 ] -= 1
elif dominance == 2 and RANDOM_PART_OF_DOMINANCE == 1 or RANDOM_PART_OF_DOMINANCE == 2 or RANDOM_PART_OF_DOMINANCE == 3 and RANDOM_PART_OF_DOMINANCE_2 == 2:
aggression[ 0 ] -= 2
aggression[ 1 ] -= 2
elif dominance == 2 and RANDOM_PART_OF_DOMINANCE == 4 and RANDOM_PART_OF_DOMINANCE_2 == 1:
aggression[ 0 ] += 4
aggression[ 1 ] += 4
elif dominance == 2 and RANDOM_PART_OF_DOMINANCE == 4 and RANDOM_PART_OF_DOMINANCE_2 == 2:
aggression[ 0 ] += 5
aggression[ 1 ] += 5
elif dominance == 1 and RANDOM_PART_OF_DOMINANCE == 1 or RANDOM_PART_OF_DOMINANCE == 2 or RANDOM_PART_OF_DOMINANCE == 3:
aggression[ 0 ] -= 1
aggression[ 1 ] -= 1
elif dominance == 1 and RANDOM_PART_OF_DOMINANCE == 4:
aggression[ 0 ] += 3
aggression[ 1 ] += 3
else:
dominance = ( int ( input ( "Enter how dominant this car is. What that means is this is how often this car leads laps and win races, compared to what is expected of a car running in that position. This value must be 1 through 8. The former is the lowest value possible: " ) )
This makes no sense to me as to why I would be getting an error. All variables listed in this program are given the value [ 0,0 ] earlier in the program.
I also imported the random module earlier in the program.
Please help :(
Aucun commentaire:
Enregistrer un commentaire