저는 프로그래밍에 익숙하지 않고 6 개의 행과 5 개의 행, 6 개의 다른 행 등이있는 "별"의 사각형을 만드는 데 필요한 할당이 있습니다. 중첩 된 루프를 사용해야하지만 첫 번째 줄을 지나칠 수는 없습니다.별표의 파이썬 사각형?
이def main():
# Setup accumulator and variable
rows = 0
stars = 0
# Get user inputs
rows = int(input("How many rows for this design?\n"))
stars = int(input("How many stars on the first row?\n"))
# Print i
for i in range(stars):
print("*", end="")
break
번째 시도 :
데프 주() : 내가 제대로 이해하면
# Get user inputs
rows = int(input("How many rows for this design?\n"))
stars = int(input("How many stars on the first row?\n"))
# Print i
for i in range(stars):
for j in range(rows):
print(stars*"*")
print(rows*"*")
break
가능한 중복과 같습니다 http://stackoverflow.com/questions/22845796/python-3-hollow-rectangle – poke
당신이 할 수 주어진 입력이나 행과 별에 대해 기대할 수있는 결과를 보여 주겠습니까? "별표의 직사각형"이 의미하는 바가 "6 행 이하, 5 행, 6 행"이라고 말할 때 분명하지 않습니다. –
입력 행 "6"에 대한 행 다음에 "5"별표가 9 번 반복되는 별표 행 : def main() : # 사용자 입력 가져 오기 행 = int ("얼마나 많은 ? 범위 내가이 디자인에 대한 행 \ n ")) 별 = INT (입력 ("몇 개의 별 첫 번째 행에 \ n ")) # 인쇄 나에게 (별) : 범위 J에 대한 휴식 – corvette1