Python Challenge - Find Xth Number In Order

def getX(x, nums):

write your code here

n = len(nums)

for i in range(n): #sorts loop in ascending order
for j in range(i + 1, n):
if nums[i] > nums[j]:
temp = nums[i]
nums[i] = nums[j]
nums[j] = temp

print(nums) #prints out the sorted list

if x > n or n == 0 or x < 0:
return 0
if x <= n:
return nums[x - 1]
#if x == n:
#return nums[n - 1]

print(getX(7, [6, 3, -1, 5, 7, 0, 6]))