Quite new to python, I am trying to create a small function that is meant to write a given number of instances of a string to a file (e.g. as input for a word cloud tool). I have tried doing this with the class below but for some reason do not receive any output, but no error message either.
I thought maybe I am not declaring count correctly as an integer as input? However, no error message is displayed which makes it somewhat confusing.
Again, very new to Python so any help along with some explanation would be greatly appreciated :) Code below!
#Prints multiple instances of a string as input for a word cloud tool
class print_list(object):
wordlist = []
def __init__(int(count), word, self):
self.count = count
self.word = word
def write_list(self):
while count > 0:
wordlist.append(word)
print word + "\n"
count = count - 1
return wordlist
def write_file(self):
my_file = open("cloud.txt", "w")
for word in wordlist:
my_file.write(word + "\n")
my_file.close
Python = print_list(10, "Python")