0
Using a range type variable as an object in a list
For example: list1 = [range(20,30),range(1000,5000)] x = int(input()) for i in list1: if x in i: print (i) I also tried assigning the ranges to variables and variables in the list. (didn't work)
10 Antworten
+ 3
How about this. Two lists for each range in parent list.
https://code.sololearn.com/c4roA6kOkI0c
+ 2
tx guys
+ 2
It is a subclass of iterable allowing it be used in a for loop created by the range function. Basically, it looks ahead one value so it knows if there is something to return next time.
https://thepythonguru.com/JUMP_LINK__&&__python__&&__JUMP_LINK-builtin-functions/range/
+ 1
hope this helps
https://code.sololearn.com/cv54xq12CaR9/?ref=app
0
Sorta, tx
0
OMG that's exactly what I thought
0
LOL
0
np.
+
In the latest code you posted you are missing a closing bracket ].
and you are comparing int to the lists so you need to use that for loop for it like you had originally
for i in list1:
if x in i:
0
What is "range object" in python?