python - limiting characters printed for loop -
This is quite a "biz talk" thing, although I want to print it 10 words or numbers per line, and also one In the same program, the user is allowed to input the range, and set the amount of words or numbers to print per line
for the i category (1,121): if i% 3 = = 0 and I% 5 == 0 and I% 7 == 0: Print ("zipzapzop") Alief I% 3 == 0 and I% 5 == 0: Print ("zippap") Alif I% 3 == 0 and I% 7 == 0: print ("zipzop") elif i% 3 == 0: print ("zip") elif i% 5 == 0: print ("zap") elif i% 7 == 0: Print ("Zop") Other: Print (i) Output:
1 2 zip 4 zap zip zop 8 zip zap 11 Zip 13 zop zipzap 16 17 zip 19 zap zipzop 22 23 zip zap 26 zip zop 29 zipzap 31 32 zip 34 zap zip 37 38 zip zap 41 zipzop 43 44 zipzap 46 47 zip zop zap 52 jip zap zop zip 58 59 zipzap 61 62 zipzop 64 zap zip 67 68 zip zap 71 zip 73 74 zippop 76 zop zip 79 jap zip 82 83 zip zop zap 86 zip 88 89 zip zap zip 92 zip 94 zap zip 97 zop zip zap 101 zip 103 104 z Ipzapzop 106 107 Zip zap zip zip zop zap zap 116 zip zop zipzap This is my output, but I want to print it 10 numbers or words per line I am not sure about this How to go
if you need a block
# bump Count the number count + = 1 # every 10 print a new line if the count% 10 == 0 print ('') then you normally disable the new line from printing How would you do this Depending on which version of Python you are using. If you are at 2.7.X then you will use <__ future__ import print_function
to
, then you will be like your prints Print ('zipzap', end = '')
Comments
Post a Comment