Shound look like this at the end in the txt fileThis part works, so you input 2 colums that exist in a table that is in a txt file. Than you need to enter a sign for example * that will replace all numbers that are in colums that you selected
m = int(input("M: "))
n = int(input("N: "))
x=int(input("Switch row:"))
y=int(input("and row:"))
doc = open("zadatak1.txt", "w")
for i in range(m,n+1):
broj=str(i)
doc.write(broj)
doc.write("\t")
for i in range(m,n+1):
doc.write("\n")
for j in range(m,n+1):
broj=str(i*j)
doc.write(broj)
doc.write("\t")
doc.write("\n\n")
sign=str(input("Enter sign to replace selected rows: "))
doc.write("Row {} and row {} switched with {}".format(x,y,sign))
for i in range(m,n+1):
if i == x +n-m+1:
doc.write(str(y+n-m+1))
elif i == y +n-m+1:
doc.write(str(x+n-m+1))
else:
doc.write(str(i))
doc.write("\t")
for i in range(m,n+1):
doc.write("\n")
for j in range(m,n+1):
if j == x +n-m+1:
doc.write(str(i*(y+n-m+1)))
elif j == y +n - m+1:
doc.write(str(i*(x+n-m+1)))
else:
doc.write(str(i*j))
doc.write("\t")
doc.close()
source https://stackoverflow.com/questions/70760574/fill-selected-columns-with-chosen-input-to-external-txt-file
Comments
Post a Comment