G
G
Guerro692020-05-27 23:17:01
Python
Guerro69, 2020-05-27 23:17:01

How to make a row and not a column in a for loop?

I wrote a code that mentions all users in cf, but there is one problem, because of the loop, it writes all users to a column, and when I tried to make it into a row, I got only one last user. Here is the code:

if message == '/an':
                    chat = vk.messages.getConversationMembers(peer_id=event.obj.peer_id, group_id=group)
                    profiles = chat['profiles']
                    for i in range(len(profiles)):
                        text = ''
                        text += f"[id{profiles[i]['id']}|{profiles[i]['first_name']} {profiles[i]['last_name']}], "
                    vk.messages.send(peer_id=event.obj.peer_id, message=text, random_id=rand)

Simply put, how not to stop the loop until it has filled the text with all users?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey, 2020-05-27
@Guerro69

Declare the variable "text" before the for loop, you get that in each iteration it is reset to zero

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question