Click here to Skip to main content
15,847,427 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
example:
e = ['6']['12']


i want to get ['6','12']

What I have tried:

ive tried join and extend functions but it didt'nt work
or I don't know if I made a mistake.
Posted
Updated 19-Jan-22 22:25pm
Comments
CPallini 20-Jan-22 3:03am    
Are you sure
e = ['6']['12']
is valid Python syntax?
shri harshan 20-Jan-22 3:10am    
yes i got a output like that the whole program is
a = int(input())
b = int(input())
c = int(input())
for i in range(a, b+1):
if i%c==0:
d = str(i)
e = d.split()
print(e,end=" ")

sample input:
5
15
6
output:
2

we need to count how many number are divible by c in range[a-b].

1 solution

Quote:
e = ['6']['12']
That's not valid Python syntax.

Quote:
yes i got a output like that the whole program is
a = int(input())
b = int(input())
c = int(input())
for i in range(a, b+1):
if i%c==0:
d = str(i)
e = d.split()
print(e,end=" ")
So it is just the output of a Python program.

Try
Python
a = int(input())
b = int(input())
c = int(input())
l = []
for i in range(a, b+1):
  if i%c==0:
    l.append(str(i))
print(l)
 
Share this answer
 
Comments
shri harshan 20-Jan-22 3:36am    
I also want to count how many elements are in l.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900