Why doesn't this work? Python3
Go to solution
Solved by Poet129,
2 hours ago, Poet129 said:Okay now what?
file1 = open("/home/akerr/Downloads/Test.txt.16", "r") file3 = open("/home/akerr/Documents/Temp.txt", "w") file3.write("") file3.close() count = 0 for line in file1.readlines( ): count += 1 s = str(count) file1.close() j = 1 l1 = 1 def ConvertBinaryToString(l1): global line1 file1 = open("/home/akerr/Downloads/Test.txt.16", "r") file2 = open("/home/akerr/Programs/AC.16", "r") l2 = 1 for line1 in file1: for line2 in file2: if (line2 == line1): temp = open("/home/akerr/Documents/Temp.txt", "a") temp.write(str(l2) + "\n") print(l2, line2) temp.close() l2 += 1 while j in range (1, int(s)): ConvertBinaryToString(l1) j += 1 l1 += 1 if (len(line1) < 16): temp = open("/home/akerr/Documents/Temp.txt", "a") print(line1) tempdata = str(line1) temp.write(tempdata) temp.close()
Output is
43211 1010100011001010
43211 1010100011001010
43211 1010100011001010
43211 1010100011001010
43211 1010100011001010
0001010
Output should be
43211 1010100011001010
59113 1110011011101000
16665 0100000010001100
53977 1101001011011000
51805 1100101001011100
0001010
The completed code
Spoiler
file1 = open("/home/akerr/Downloads/Test.txt.16", "r") file3 = open("/home/akerr/Documents/Temp.txt", "w") file3.write("") file3.close() count = 0 for line in file1.readlines( ): count += 1 s = str(count) file1.close() j = 1 l1 = 1 def ConvertBinaryToString(l1, file1): global line1 file2 = open("/home/akerr/Programs/AC.16", "r") l2 = 1 for line2 in file2: if (line2 == line1): temp = open("/home/akerr/Documents/Temp.txt", "a") temp.write(str(l2) + "\n") print(l2, line2) temp.close() l2 += 1 while j in range (1, int(2)): file1 = open("/home/akerr/Downloads/Test.txt.16", "r") for line1 in file1: ConvertBinaryToString(l1, file1) j += 1 l1 += 1 if (len(line1) < 16): temp = open("/home/akerr/Documents/Temp.txt", "a") print(line1) tempdata = str(line1) temp.write(tempdata) temp.close()
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now