lundi 3 avril 2017

How to write to multiple lines in a file using variables in python 3.5

I need some help with this code which has me very confused and I am grateful for any help received, thanks

CODE STARTS:

import random

a=('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9')

for ii in range (0,5):

        into = open("C:/Documents/FourCharacterCombinations.txt", "w+")

        x=input('Press enter to start ')

        b=(random.choice(a))
        c=(random.choice(a))
        d=(random.choice(a))
        e=(random.choice(a))

        if ii == 0:
                print("ZERO")
                f=((b)+(c)+(d)+(e))
                into.write(f + '\n')
        if ii == 1:
                print("ONE")
                g=((b)+(c)+(d)+(e))
                into.write(g + '\n')
        if ii == 2:
                print("TWO")
                h=((b)+(c)+(d)+(e))
                into.write(h + '\n')
        if ii == 3:
                print("THREE")
                i=((b)+(c)+(d)+(e))
                into.write(i + '\n')
        if ii == 4:
                print("FOUR")
                j=((b)+(c)+(d)+(e))
                into.write(j + '\n')

        ii += 1

into.close()




Aucun commentaire:

Enregistrer un commentaire