I have been experiementing with this code for a couple hours and have come across an issue with each implementation. I can no longer put in any time at the moment so I figured I would go ahead and ask. As of now it keeps telling me that "else" is invalid syntax and when I try to implement it without the else my returns have issues and are outside the function. Here is my code:
from cs50 import get_int
condition = True
# originally n < 1 or n >8
while condition:
n = get_int("Height:") in range(8)
if n != range:
print("Pick a number between 1 and 8 please!")
return
else:
return False
for i in range(n):
for j in range(n):
if i + j < n - 1:
print(" ")
else:
print("#")
Updated code:
from cs50 import get_int
condition = True
# originally n < 1 or n >8
while condition:
n = get_int("Height:") in range(8)
if n > 0 and n < 8:
break
for i in range(n):
for j in range(n):
if i + j < n - 1:
print(" ")
print("#")