python - Write a program that reads a file with numbers separated by commas and print those numbers to the turtle screen -


question: write program reads in sequences of numbers file , displays them in grid on graphics screen. program, can assume there 4 lines each no more 4 entries per line. entries on each line separated commas.

for example, consider file contains:

12,13,14,15 8,9,10,11 4,5,6,7 0,1,2,3 

this program:

from turtle import*  def file():   filename = input("please enter filename: ")   openfile = open(filename, "r")   readlines = openfile.readlines()    lines in readlines:     nums = lines.strip().split(",")    return nums  def turtle(n):   row = 0   wn = screen()   pen = turtle()   wn.setworldcoordinates(-0.5,3.5,4.5,-1.0)   row = row + 1   pen.up()   in range(len(n)):     pen.goto(i,row)     pen.write(i, font=("arial", 30))   row = row + 1   def main():   y = file()   w = turtle(y)   main() 

this program working, printing last row numbers file. please help!

from turtle import*  def file():     filename = "t.txt"     openfile = open(filename, "r")     readlines = openfile.readlines()     nums=[]     lines in readlines:         nums.append(lines.strip().split(","))      return nums  def turtle(n):     print(n)     row = 0     col = 0     wn = screen()     pen = turtle()     wn.setworldcoordinates(-0.5,3.5,4.5,-1.0)      pen.up()     numberrow in n:         number in numberrow:             pen.goto(col,row)             pen.write(number, font=("arial", 30))             col+=1         row += 1         col = 0  def main():     y = file()     w = turtle(y)   main() r = input() 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -