Some problems with code


Joined
Sep 18, 2022
Messages
1
Reaction score
0
program to print the repeated list in such a way that 1st element which gets repeated multiple times should be printed twice, the next should be printed thrice and so on.
 
Ad

Advertisements

Joined
May 11, 2022
Messages
51
Reaction score
3
Code:
data = input().split()
counter = 2
assign = []
delete = []
i = 0
while i < len(data):
   if data[i] in assign:
      if data[i] in delete:
         i += 1
         continue
      j = counter
      while j >0:
         print(data[i])
         j -= 1
      counter += 1
      delete += [data[i]]
   else:
      assign += [data[i]]
   i += 1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top