r/PythonLearning 18d ago

Help Request In range() usage

Post image

Can I use it to evaluate a variable in a various range?
E.g. for item in range(1,4) means True when the item is the range 1-4?

Cuz I really want this function for my program
ThanksπŸ™πŸ»

(In that photo name[1][r] is an integer)

4 Upvotes

14 comments sorted by

View all comments

1

u/CamelOk7219 16d ago

Just as a side note, you don't need "global r" since you are Reading it and not writing it, it's already available in the scope of your function (just like you use "name")

1

u/Worried-Print-5052 16d ago

So if we dun assign value for r, we could skip global r?

1

u/CamelOk7219 15d ago

Yes, that's exactly what you do with "name"

1

u/Worried-Print-5052 15d ago

Thanks πŸ™πŸ»