# string concatenation result = "" result += "Election Results\n" result += "------------------------\n" result += "------------------------------ \n" result += f"Total Votes: {total_vote} \n" result += "------------------------------ \n" result += "------------------------------- \n" result += f"Winner : {winner_name} \n" result += "-------------------------------" print(result) # wiring text file with open("PyBank.txt", "w") as file: file.write(result)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter