My issue
runtime error
My code
def bubbleSort(arr):
n = len(arr)
# Outer loop for n-1 passes
for i in range(n - 1):
# Inner loop for comparing adjacent elements
for j in range(n - 1 - i):
# Swap if the current element is greater than the next element
if arr[j] > arr[j + 1]:
arr[j], arr[j + 1] = arr[j + 1], arr[j] # Swap elements
def main():
try:
# Read number of elements in the array
n = int(input().strip())
# Read the array elements
arr = list(map(int, input().strip().split()))
# Call the bubbleSort function to sort the array
bubbleSort(arr)
# Output the sorted array
print(*arr)
except EOFError:
print("No input provided.")
except ValueError:
print("Invalid input format.")
if __name__ == "__main__":
main()
# Write your code here
Learning course: Data structures & Algorithms lab
Problem Link: https://www.codechef.com/learn/course/muj-aiml-dsa-c/MUJADSAC13/problems/SESO16