Skip to content

Commit b7a523b

Browse files
committed
Adding Nested For
1 parent 3d24d37 commit b7a523b

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

basics/For Loop/challenge.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@
2424

2525

2626
while chances > 0:
27+
print(f"Chances left: {chances}")
2728
user = input("Enter your username: ")
2829
passw = input("Enter your password: ")
29-
print(f"Chances left: {chances}")
3030
for i in range(len(username)):
3131
if username[i] == user and password[i] == passw:
3232
print(f"Welcome {username[i]}")
3333
break
3434
else:
3535
print("Account not found")
3636
chances -= 1
37+
break

basics/NestedFor/range.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
for x in range(5):
2+
for y in range(x+1):
3+
print("*", end=" ")
4+
print()
5+
6+
# Code to print a heart shape using asterisks (*)
7+
for row in range(6):
8+
for col in range(7):
9+
if (row == 0 and col % 3 != 0) or (row == 1 and col % 3 == 0) or (row - col == 2) or (row + col == 8):
10+
print("*", end=" ")
11+
else:
12+
print(" ", end=" ")
13+
print()
14+

0 commit comments

Comments
 (0)