Question:
Python programming question?
NDSUstudent
2009-04-08 21:02:16 UTC
im having trouble with a homework problem. I need to design and write a python program that involves nested FOR loops. The program must accept a string containing a single letter from the user. The program will print succesive letters, 6 in the first row, 5 in the next etc. here are two examples

a b c d e f
g h i j k
l m n o
p q r
s t
u

we have been given a hint to use ord(ch) and chr(i). So far i have this :

def main():
letter = raw_input("Enter a letter: ")
for i in range(6):
for j in range(i,6):
print letter," ",





main()


can anyone help me?
Four answers:
2009-04-12 14:25:12 UTC
+ means tab



def main():

+letter = raw_input("Enter a letter: ")

+ch = ord(letter)

+for i in range(6):

++for j in range(ch + i, ch + 6):

+++print chr(j),

+++ch += 1

++print ''

++ch -= 1



main()
Carling
2009-04-08 21:09:07 UTC
Join a Python user group for the best answers website user group list list below
?
2016-10-14 09:29:09 UTC
in case you have examine something approximately sound in "Console-Mode" Python, this is because of the fact there is not any sound characteristic with Console Python. attempt to earnings wxPython or PyGame or possibly even Tkinter (i think of helps sound good factors)
Thrus Rina 3
2009-04-08 22:55:36 UTC
You may contact a python expert live at website like http://ijug.net/ ,etc .


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...