+ 7
Working with lists
finally i get the right result With my Code. But goes it easier? https://code.sololearn.com/cQsgd9J7zYi0/?ref=app
11 Respuestas
+ 8
https://code.sololearn.com/cth8s2EooHDj/?ref=app
+ 4
You can "zip" the two `list` and extend <lst> by a tuple created from comprehension.
lst = []
for ( value, counter ) in zip( times, people ):
lst.extend( ( value for x in range( counter ) ) )
print( lst )
+ 2
Using itertools.chain:
https://code.sololearn.com/ciJHs57S13um/?ref=app
+ 2
A quick C version with output in Python style.
https://code.sololearn.com/cqOG5PXAdvnZ/?ref=app
+ 2
Thanks @ all, so many new things for me.
+ 2
You can do it using the Lambda and List comprehension:
times = [0,1,2]
people = [4,8,3]
result = []
y = lambda n: [((str(times[n]))*(people[n])) for n in range(3)]
# print(y(n))
[[result.append(int(j)) for j in i] for i in y(n)]
print(result)
#range can be taken as (len(times)) or (len(people))
+ 1
Yusra I recommend you to start Python for Beginners course on Sololearn
https://www.sololearn.com/Course/Python-for-Beginners/?ref=app
0
Hii
0
Sir I want python code for 7425 ÷550
0
Pls I'm new and I don't understand any single thing in phython
0
Bro I want a help from you can you help me?