+ 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)
18 Antworten
+ 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)
+ 8
the answer you've been waiting for
a=int(input())
b=int(input())
numbers=list(range(a,b))
print(numbers)
+ 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
+ 2
Here is my code
a = int(input())
b = int(input())
years = list(range(a, b))
print(years)
+ 2
a = int(input())
b = int(input())
years = list(range(a,b))
print(years)
+ 2
a = int(input())
b = int(input())
years = list(range(a, b))
print(years)
done...!
+ 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
+ 1
#Also
lower_bound = int(input())
upper_bound = int(input())
print(years_list := list(range(lower_bound, upper_bound)))
+ 1
Check this out;
a = int(input())
b = int(input())
c = list(range(a,b))
print(c)
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
0
a = int(input())
b = int(input())
yea=list(range(a, b))
for x in yea:
print(yea)
break
0
a = int(input())
b = int(input())
years = list(range(a, b))
print(years)
0
a = int(input())
b = int(input())
dates= list(range(a, b, 1))
print(dates)
0
a=int(input())
b=int(input())
numbers=list(range(a,b))
print(numbers)
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.
0
a = int(input())
b = int(input())
list1=[]
for i in range(a,b,1):
list1.append(i)
print(list1)
0
a = int(input())
b = int(input())
x = list(range(a,b))
print(x)
- 1
a=int(input())
b=int(input())
for i in range(a,b):
print(i)