+ 10

Python question/problem (range)

You are making a date picker for a website and need to output all the years in a given period. Write a program that takes two integers as input and outputs the range of numbers between the two inputs as a list. The output sequence should start with the first input number and end with the second input number, without including it. Sample Input 2005 2011 Sample Output [2005, 2006, 2007, 2008, 2009, 2010] My code is A = int(input()) B = int(input()) number = list(range(1,10)) print (numbers)

1st Dec 2020, 5:48 PM
Yazan
18 Answers
+ 8
If you observe output of your code, you can find what is needed solution.. Here is solution... Read about range() function for more info... numbers = list(range(A, B)) print(numbers)
1st Dec 2020, 6:04 PM
Jayakrishna šŸ‡®šŸ‡³
+ 8
the answer you've been waiting for a=int(input()) b=int(input()) numbers=list(range(a,b)) print(numbers)
6th May 2021, 5:25 PM
Alok Jha
Alok Jha - avatar
+ 6
Yazan , there are several issues in the code: - the range you create does give 10 numbers 1,2,..., but you should generate the years instead. So use A and B to create the range - print() has an indentation that is not correct here - print(numbers) does create an error, as numbers is not defined. correct name is number
1st Dec 2020, 6:07 PM
Lothar
Lothar - avatar
+ 2
Here is my code a = int(input()) b = int(input()) years = list(range(a, b)) print(years)
10th Dec 2021, 8:27 AM
Aditya
Aditya - avatar
+ 2
a = int(input()) b = int(input()) years = list(range(a,b)) print(years)
28th Dec 2021, 2:48 PM
Clean Code
+ 2
a = int(input()) b = int(input()) years = list(range(a, b)) print(years) done...!
5th Mar 2022, 2:48 PM
Nikhila
+ 1
s=int(input('enter the start value of year: ')) e=int(input('enter the end value of year: ')) l=[] while(s<e): l.append(s) s=s+1 print(l) very simple code
22nd Dec 2021, 11:51 AM
SANVIKA
+ 1
#Also lower_bound = int(input()) upper_bound = int(input()) print(years_list := list(range(lower_bound, upper_bound)))
19th Feb 2022, 11:50 AM
Matumbai Binale
Matumbai Binale - avatar
+ 1
Check this out; a = int(input()) b = int(input()) c = list(range(a,b)) print(c)
27th Jan 2023, 6:04 AM
Himasha Nethmini
Himasha Nethmini - avatar
0
This is the proper solution to this exercise: a = int(input()) b = int(input()) #your code goes here years = list(range(a, b)) for x in years: print(years) break
8th Feb 2022, 6:56 PM
Antonio Gutierrez
0
a = int(input()) b = int(input()) yea=list(range(a, b)) for x in yea: print(yea) break
23rd Feb 2022, 9:43 AM
MANOJ BABU MALLAKUNTA
0
a = int(input()) b = int(input()) years = list(range(a, b)) print(years)
28th Mar 2022, 2:46 PM
AMM SAJEETH
0
a = int(input()) b = int(input()) dates= list(range(a, b, 1)) print(dates)
31st Mar 2022, 12:24 PM
Ahmed Salouh Abdelmoried
0
a=int(input()) b=int(input()) numbers=list(range(a,b)) print(numbers)
15th Nov 2022, 8:01 AM
Pooja Patel
Pooja Patel - avatar
0
a = int(input()) b = int(input()) list = list(range(a,b)) print(list) This is the suitable answer for this program and make sure pls right this program as same as written.
1st Jan 2023, 4:05 PM
Prince Yadav
Prince Yadav - avatar
0
a = int(input()) b = int(input()) list1=[] for i in range(a,b,1): list1.append(i) print(list1)
21st Feb 2023, 7:42 PM
KAAS Kodithuwakku-s22010212-622515809
KAAS Kodithuwakku-s22010212-622515809 - avatar
0
a = int(input()) b = int(input()) x = list(range(a,b)) print(x)
17th Oct 2023, 1:48 PM
Sibusiso Dyan
Sibusiso Dyan - avatar
- 1
a=int(input()) b=int(input()) for i in range(a,b): print(i)
7th Feb 2022, 10:45 AM
Ashish Sharma