Answer the question
In order to leave comments, you need to log in
How to implement the output of data from the database based on the number of data?
The user creates a request to the database. Upon request, an array with the number of lists from one to infinity can come out. Depending on the number of lists, you need to correctly display information to the user.
Example:
data = cursor.fetchall()
#data - accordingly, the resulting array, for example - [(1, 2, 3), (1, 2, 3), (1, 2, 3), (1, 2, 3 )...]
With the help of len(data) I'll get the number of lists in the array
And then I still can't figure out what to do.. The answer should be in the message, two lines each. The number of messages should depend on the number of lines.
#sms - message
sms = data[0] #if one line
sms = data[0], data[1] #if two
If more than two, then only 0-1 should be taken from the data array, then 2 or 2-3 lines etc
How to do it?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question