0

why in first sentence ,lenth is 3 but print it out if content is 0,3 ?

numbers =range(3) print(len(numbers)) print(numbers) print("-----") numbers = list(range(10)) print(len(numbers)) print(numbers) print("-----") numbers = 1,2,3,4 print(len(numbers)) print(numbers) print("-----")

25th Jul 2020, 5:15 AM
搳漗掟
搳漗掟 - avatar
2 Answers
+ 7
搳漗掟 ##why in first sentence ,lenth is 3 but print it out if content is 0,3 ? ## Because your range you preset as 3 numbers =range(3) print(len(numbers)) print(numbers) print("-----") ## Here you prest your list range as 10 numbers = list(range(10)) print(len(numbers)) print(numbers) print("-----") ## Here you defined numbers as a set of 4 numbers = 1,2,3,4 print(len(numbers)) print(numbers) print("-----")
25th Jul 2020, 5:21 AM
BroFar
BroFar - avatar
0
BroFar ##why in first sentence ,lenth is 3 but print it out if content is 0,3 ? #yes,I knew it, i define volume of numbers as 3 , From my concept ,it should be [0,1,2], but print (numbers) is [0,3] ## Because your range you preset as 3 numbers =range(3) print(len(numbers)) print(numbers) print("-----")
25th Jul 2020, 12:47 PM
搳漗掟
搳漗掟 - avatar