Python Forum
Cant get grade part of code to work correctly
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cant get grade part of code to work correctly
#6
Suggestion regarding code.

Code should be DRY (don't repeat yourself). Every time you find yourself writing repeating rows you should stop and think what should you do differently. Don't use Python as typing machine, it's programming language.

You can ask user input with loop (requires 3.6 <= Python as f-string is used):

>>> answers = list()
>>> for i in range(5):
...     answers.append(int(input(f'Enter total of 5 numbers ({i+1}/5): ')))
... 
Enter total of 5 numbers (1/5): 4
Enter total of 5 numbers (2/5): 5
Enter total of 5 numbers (3/5): 5
Enter total of 5 numbers (4/5): 3
Enter total of 5 numbers (5/5): 4
>>> answers
[4, 5, 5, 3, 4]
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
RE: Cant get grade part of code to work correctly - by perfringo - Jul-10-2019, 05:09 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  I can't for the life of me get this basic If statement code to work CandleType1a 8 554 May-21-2024, 03:58 PM
Last Post: CandleType1a
  Why can I not see the code correctly in Python IDLE.? Trump 8 990 Apr-04-2024, 07:47 AM
Last Post: jonesphedra
  Remove part of the code hack3rcon 5 865 Jan-08-2024, 10:25 AM
Last Post: hack3rcon
  hi need help to make this code work correctly atulkul1985 5 1,045 Nov-20-2023, 04:38 PM
Last Post: deanhystad
  newbie question - can't make code work tronic72 2 855 Oct-22-2023, 09:08 PM
Last Post: tronic72
  Beginner: Code not work when longer list raiviscoding 2 985 May-19-2023, 11:19 AM
Last Post: deanhystad
  Why doesn't this code work? What is wrong with path? Melcu54 7 2,132 Jan-29-2023, 06:24 PM
Last Post: Melcu54
  Code used to work 100%, now sometimes works! muzicman0 5 1,670 Jan-13-2023, 05:09 PM
Last Post: muzicman0
  color code doesn't work harryvl 1 1,047 Dec-29-2022, 08:59 PM
Last Post: deanhystad
  Coding problem portfolio grade max70990 1 819 Dec-11-2022, 12:30 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020