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.
 
Joined
May 11, 2022
Messages
61
Reaction score
6
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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top