Write code that generates a list of N elements in
range from 1 to 100. Display the list on the screen. Insert value into list
k (keyboard value) in front of all elements,
ending with the number 8.
import random
n = int (input ('Enter the number of list items') )
list = [random.randint (1, 100) for i in range (n) ]
print (list)
number = int (input ('Enter value.') )
l = [list.index (list % 10 == 8)]
while list % 10 == 8:
list.insert (number)
>Solution :
You can use range() instead.
l = list(range(1,100))
print(l)
k = []
for i in l:
if i%10==8:
k.append(i)
print(k)