So basically i am having trouble with this part of this project I'm working on. I need to create a competitor that has a random amount of viewers, which I have gotten. Then I need to have each viewer watch 1 video on the channel that is between 1 and 5 minutes long (which I made a list 1-5 but idk if I should just do random instead). Then I need Compute the total amount of minutes your competitor’s viewers spent watching their channel. And then figure out which channel had more watch time. Output whether it was your channel, their channel, or a tie! To make sure that you’re correct, output the total time watched for each channel. My code for this part so far:
comp = random.randint(1,100)
compvidlen = (1,2,3,4,5)
total_time2 = 0
total_time_eachvid2 = {}
print("Your competitor has", comp,"subscribers")
if comp >= 0:
print('Competitors watch time statistics:')
for i in range(comp):
choice2 = random.choice(compvidlen)
if choice in total_time_eachvid2:
total_time_eachvid2[choice2] += choice2
else:
total_time_eachvid2[choice2] = choice2
print("Subsriber watched for", compvidlen[choice2], "minutes.")
total_time2 += choice2
print('\n')
print("Total Time spent by all viewers is:", total_time2)
print("Total time spent on each video", total_time_eachvid2)
another issues I just notices is that I dont need to display time per video like the last step that I already solved, I just need to show total.
Aucun commentaire:
Enregistrer un commentaire