python - Number 1 to Z input using def operator -
i'm having trouble question, , don't know start:
write function prints characters using following header:
def printchars(ch1, ch2, numberperline):
this function prints characters between ch1 , ch2 specified numbers per line. write test program prints ten characters per line 1 z.
i have far:
import string
import random ch1 = 1 ch2 = str('chr(90)') char_line = 10 numberoflines = 36 def printchars(ch1,ch2,char_line): in range(numberoflines): = 0 while in range(numberoflines): += 0 print(string.digits) print(string.ascii_uppercase) if <= char_line: print('\n') elif >=36: return printchars(ch1,ch2,char_line)
and when inputted, repetition of
0123456789 abcdefghijklmnopqrstuvwxyz
when should getting
1234567890 abcdefghij klmnopqrst uvwxyz
p.s. i'm newcomer stackoverflow, , i'm still learning system
i think you're on complicating things - need iterate ch1
ch2
, keep track of how many characters had in current line - if it's numberperline
, print linebreak:
def printchars(ch1, ch2, numberperline): in range(ord(ch1), ord(ch2) + 1): print(chr(i), end='') if (i - ord(ch1)) % numberperline == numberperline - 1: print()
Comments
Post a Comment