You are on page 1of 1

Akash Sharma, COMP-B:70

PS FA1

def mineral_formation(cave):
first_row = cave[0]
last_row = cave[-1]
if all(val == 0 for val in first_row):
return "stalagmites"
elif all(val == 0 for val in last_row):
return "stalactites"
else:
return "both"
def main():
cave = []
rows = int(input("Enter the number of rows in the cave: "))
cols = int(input("Enter the number of columns in the cave: "))
for i in range(rows):
row = []
for j in range(cols):
val = int(input(f"Enter the value at index ({i}, {j}): "))
row.append(val)
cave.append(row)
print("The formation is:", mineral_formation(cave))

if _name_ == "_main_":
main()
Output:

You might also like