I am trying to add variable information from an input to a text document. The document is in the place it should be. I have this code so far:
import time
import os
print("Welcome!")
name = input("Please enter your name: ")
print("Hello",name, "! I am going to guess your most favorite type of music.")
time.sleep(2)
print("Please, choose from one of the following: ")
listening_time = ["1 - One hour a day", "2 - About two hours per day", "3 - three to four hours per day", "4 - Most of the day"]
print(listening_time)
how_often = int(input("I find myself listening to music..."))
def add_file_1(new_1):
f = open("music.txt", "a")
f.write("1 Hour")
def add_file_2(new_2):
f = open("music.txt", "a")
f.write("2 Hours")
def add_file_3(new_3):
f = open("music.txt", "a")
f.write("3 - 4 Hours")
def add_file_4(new_4):
f = open("music.txt", "a")
f.write("Most of the day")
if how_often == str('1'):
add_file_1(new_1)
elif how_often == str('2'):
add_file_2(new_2)
elif how_often == str('3'):
add_file_3(new_3)
else:
add_file_4(new_4)