Only 3 lines of code 😱⁉️ #computerscience #coding #stem #programming #python

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

Lmaoo this question so easy that you had to repost it with a better solution you got from the comments 😂. You were using a for loop with 2 more nested in it originally, you’ve come a long way but keep going. You can do it in 1 line (inline minus the function) :

for i in range(n): print(“ “ * (i)) + (“* “ * 4)

ritvikkhurana
Автор

This was nice, even though you can compress it further by comprehension.

def rhombus(n: int):
print(*["\n" * (1 if i > 0 else 0) + " " * i + "* " * n for i in range(n)])
rhombus(4)

I added new line at the start of each string for all except the first string and then just put everything in the print function to reduce the number of lines; actual 3 lines of code XD assuming you need a function

marilynman
Автор

Nice try but this code beats it.

def main(number):
for i in range(number):
print(i*" "+"* "*number)
main(4)

program.
Автор

Why your Ai course not listed I want Ai course

MueenSeoCopywriter
welcome to shbcf.ru