简体   繁体   中英

How do I make a rectangle with user input?

I need to make a square with 2 pieces of user input: n and m . The rectangle has to be n * m and made out of "*" . I can make the square if I say for example n = (5) and m = (7) , when I add make m and n user input it prints n instead of a rectangle made of "*" ... This is what I have so far, what am I doing wrong?

n = int(input(3))
m = int(input(4))
for i in range(n):
    print ('*' * m)

The expected output is:

****
****
****

Edit: Ok, I think my problem is that I don't know how to correctly enter input, can anyone help me on that? Second Edit: Alright, thanks everybody for helping! I found out how it works, I didn't enter actual input after running the program. Thanks again!

This creates a rectangle.

n = int(input("First number "))
m = int(input("Second number "))
star = "*"
for i in range(n):
    print(star*m)

Example:

First number 4
Second number 8
********
********
********
********

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM