Python Forum
Need help with loops!
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with loops!
#4
The first 16 lines of your code are the same 4 lines repeated 3 times. Almost any time you're copy-pasting code, you could clean it up and write a function that does it cleaner. In this case, those code could be replaced with a function, and then just calling it three times, like so:
sValue = get_int_input("Enter the starting value")
eValue = get_int_input("Enter the ending value")
iValue = get_int_input("Enter the increments you'd like to count in")
Unrelated, but those aren't great variable names. They don't give any indication as to what they mean, aside from the fact that they hold some sort of value. But holding a value isn't meaningful, since that's what all variables do :p
The program won't go faster if you use smaller variable names, so it's better for you (and anyone else who reads the code) to use meaningful names. In this case, something like starting_point, ending_point, and increment_by perhaps.
Reply


Messages In This Thread
Need help with loops! - by Funnypants - Dec-03-2018, 04:53 PM
RE: Need help with loops! - by nilamo - Dec-03-2018, 05:35 PM
RE: Need help with loops! - by Funnypants - Dec-03-2018, 05:50 PM
RE: Need help with loops! - by nilamo - Dec-03-2018, 06:07 PM
RE: Need help with loops! - by Funnypants - Dec-03-2018, 07:41 PM
RE: Need help with loops! - by dossantanos - Dec-05-2018, 04:48 PM

Forum Jump:

User Panel Messages

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