I'm barely new to python and stumble upon a problem that I can't really find an answer to online so here I ask. I am trying to make a basic algorithm that calculates the mean of an ungrouped data
#List or array of ungrouped data
ungrouped_data = [1, 2, 3, 4]
summation = 0
mean = 0
#for loop to sum all the data and print it out
print("Ungrouped data: ")
for x in ungrouped_data:
summation += x
print(x, end=", ")
#Calculate the mean by dividing the summation of x to the total number of list
mean = summation/len(List)
#Print the mean result
print()
print(f"Mean = "+ str(mean))
I was trying to print the string "ungrouped data" along with the list of data in a single horizontal line.
Ungrouped data: 1, 2, 3, 4
Mean = 2.5
But was struggling to do it and ended up having this.
Ungrouped data:
1, 2, 3, 4
Mean = 2.5
The question is, how can I use two separate print() function to print a text in a single horizontal line