Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
623 B
2
Indexable
Never
def generate_output(word, start_year, end_year, filename):
    with open(filename, 'w') as f:
        for year in range(start_year, end_year + 1):
            output = word.upper()
            for i in range(len(word)):
                output += '\n' + word[:i] + word[i].upper() + word[i+1:]
            output += str(year) + '\n\n'
            f.write(output)

# contoh penggunaan program
word = input('Masukkan kata: ')
start_year = int(input('Masukkan tahun awal: '))
end_year = int(input('Masukkan tahun akhir: '))
filename = input('Masukkan nama file output: ')

generate_output(word, start_year, end_year, filename)