0
how do i assign same variable to each element in list?
i was making line graphs in matplotlib and I wanted to have 1 line for data, some other for mean, median, std deviation,etc. to visualise them. so here I want to make a dataframe with same value for each row in mean, median, std dev,etc. columns. sorry my description is unclear, but just tell me is there any shortcut to create list with same value x amount of times.
1 Answer
+ 2
x = 5
print([3.14]*x)
output: [3.14, 3.14, 3.14, 3.14, 3.14]