0

I want to limit a number onto a specific range in Python, I will be updating this number through the code constantly so I would prefer it to be a class or something that i can just reuse or call.

When I say limit in a range I mean that number can't be higher than 100 or lower than 0 for example.

I am pretty new to programming and python and i would appreciate if you could explain to me your solutions please.

Thanks.

Hagogs
  • 53
  • 1
  • 9
  • 2
    What do you mean limit? Randomly? Incrementally? – AChampion Aug 24 '17 at 00:03
  • 1
    This question is far too broad, can you show an example of you you'd like to input this value and how it will be used. Also as a side note, please read the description of the tags you are adding to your question, python-requests is referring to an HTTP library, which has nothing to do with your question. – Cory Kramer Aug 24 '17 at 00:03
  • 1
    You mean like in https://stackoverflow.com/questions/5996881/how-to-limit-a-number-to-be-within-a-specified-range-python? – Izaak van Dongen Aug 24 '17 at 00:04
  • https://stackoverflow.com/a/33496902/4909087 Lol – cs95 Aug 24 '17 at 00:07
  • I just edited my original post to be more specific and clearer. – Hagogs Aug 24 '17 at 00:21
  • @Hagogs, would it be something like this? https://repl.it/KXOo/1 – chickity china chinese chicken Aug 24 '17 at 00:59
  • Idk, like i said I am pretty newish to programming, while i have some basic knowledge I didin't udnerstood most of the answers i got froms earching on google, most assume you already know everything. – Hagogs Aug 24 '17 at 01:05
  • @Hagogs, That's okay, but did you run the code I put in the link? I'm trying to help answer your question. – chickity china chinese chicken Aug 24 '17 at 01:13
  • I managed to create a function to do it!!! now i just need to know how to adapt it to a class so i can use it through the code. – Hagogs Aug 24 '17 at 19:56

0 Answers0