Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1275

Python • Help with the code

$
0
0
Hello, I have this code,which is used for x axis on graph. It shows names like januar, februar, ... on x axis

Code:

months = [1,2,3,4,5,6,7,8,9,10]month_labels = [    # Generate a list of tuples (x_value, x_label)    (m, datetime.date(2020, m, 1).strftime('%B'))    for m in months]print(month_labels)

which gives an output:

Code:

[(1, 'januar'), (2, 'februar'), (3, 'marec'), (4, 'april'), (5, 'maj'), (6, 'junij'), (7, 'julij'), (8, 'avgust'), (9, 'september'), (10, 'oktober')]
What I want is to have my own x axis - example:

Code:

my_x_axses = [1,2,3,4,5,6,7,1,2,3]
and desired output of the code would be:

Code:

[(1, '1'), (2, '2'), (3, '3'), (4, '4'), (5, '5'), (6, '6'), (7, '7'), (8, '1'), (9, '2'), (10, '3')]
So, the question is how to get desired output?

Regards, Vlado

Statistics: Posted by California — Fri Aug 30, 2024 12:04 pm



Viewing all articles
Browse latest Browse all 1275

Trending Articles