I just started programming with python 2.7, and I have some trouble with my random generator for taking items from an outside .txt file, wondering if anyone could help me a little bit...
Basically Id like to take 100 random hits, and count them all up in the end, and print the summary for the strings. I hope it makes sense!
I know this question has been answered before, but the answeres havent helped me.
So, my txt file contains a bunch of strings, separated with commas. This is what my code looks like:
import random
fname = raw_input("Enter filename: ")
infile = open(fname,'r')
data = infile.readlines()
for i in range(100):
print(random.uniform("Car_types.txt"))
Thanks for your help in advance!
Aucun commentaire:
Enregistrer un commentaire