Making a hollow box in Python to these specifications?

前端 未结 5 999
盖世英雄少女心
盖世英雄少女心 2021-01-28 06:26

I\'m to \"Write a python program that prompts the user to input a positive integer n. The program then prints a hollow rectangle with n rows and 2*n columns. For a example an in

5条回答
  •  Happy的楠姐
    2021-01-28 06:57

    My solution is more elementary. Please consider it :

    row = abs(eval(input('Enter row: ')))
    col = abs(eval(input('Enter column: ')))
    print ('*'*col)
    
    for i in range (row-2):
          print ('*'+' '*(col-2)+'*')
    print ('*'*col)
    

提交回复
热议问题