#๐Ÿ”’ Learning to code again, simple question

9 messages ยท Page 1 of 1 (latest)

sharp sandalBOT
#

@pure wyvern

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

pure wyvern
#

#variables and/or constants
cont = 0 #continue or not
par1 = 0 #par for the course played
par2 = 0
par3 = 0
par4 = 0
par5 = 0
par6 = 0
par7 = 0
par8 = 0
par9 = 0
par10 = 0
shot1 = 0 #what the user shot on the specified course par
shot2 = 0
shot3 = 0
shot4 = 0
shot5 = 0
shot6 = 0
shot7 = 0
shot8 = 0
shot9 = 0
shot10 = 0
averagepar = 0
averageshot = 0

#get the user to input the par for the course played and what they shot on it

par1 = int(input('Enter the par for the first course you played: '))
shot1 = int(input('Enter the score you got on the course: '))
cont = int(input('Press 1 for results or press 2 to continue adding scores '))
if cont == 1:
if shot1 == par1:
print("You're a scratch golfer! Congratulations")
print('Press ENTER to exit this program')
else:
print('Your handicap is',(shot1 - par1))
print('Press ENTER to exit this program')
elif cont == 2:
par2 = int(input('Enter the par for the second course you played:'))
shot2 = int(input('Enter the score you got on the second course you played'))
cont = int(input('Press 1 for results or press 2 to continue adding scores'))

sharp sandalBOT
#

Hey @pure wyvern!

It looks like you're trying to paste code into this channel.

Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes it easier for us to help you.

To do this, use the following method:
```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
You can **edit your original message** to correct your code block.
pure wyvern
#

Sorry for confusion, I am very new here. I am trying to make a program to calculate a golfer's handicap to practice my coding. Is there a better way for the user to input as many values as they want for me to average them without individually defining every par and shot?

vocal star
#

A loop and a list. Any time you make a lot of variables with numbers in the name, it's a time to consider using lists

#

Also, unless you will use the pars and shots afterwards, you can just reuse the same variables (overwriting previous value)

pure wyvern
#

thank you for the help, i will look up loops and lists and hopefully solve my issue ๐Ÿ™‚

sharp sandalBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.