n = int(input("Enter a number: ")) # taking input
result = [] # creating an empty list, and its variable is result
grade = [] # creating an empty list , to store marks of each student
for i in range(n): # iterating through the given input
name = input() # taking name , from input and assigining to the variable name is name
mark = float(input()) # taking grade , from the input and assinging to the variable mark
result.append([name,mark]) # in result , appending name And mark as list HERE I AM GIVING A LIST INTO ANOTHER LIST.
grade.append(mark) # appending the marks into a grade list
grade = sorted(set(grade)) #sorting the marks list uniquely
m = grade[1] # taking second lowest grade and append to m .
name = [] # taking an empty list , to store names
for item in result: # iterating from reuslt
if m == item[1]: # checking condition m is equal to item[1]
name.append(item[0]) #appendting item into name
# here we get two names because in example there are two same numbers so, sorting names
name.sort()
for val in name :
print(val)
Enter a number: 3 chi 20.0 beta 50.0 alpha 50.0 alpha beta
nums = list[int(input("Enter a list of Elements: "))] # taking input from user as list
nums = len(nums)
target = int(input()) # taking a target value as int
dictionary = {} # creating a null dictionary
for i in range((nums)): #iterating through the number of items in a list
if nums[i] in dictionary : # checking if num[i] is availabe in dictionary we will return nums[i],i
print([dictionary[nums[i]],i])
else:
dictionary[target - num[i]] = i # we were checking dictionary[target number - num[i]] = i
Enter a list of Elements: 2 7 11 10
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In[10], line 1 ----> 1 nums = list[int(input("Enter a list of Elements: "))] # taking input from user as list 3 nums = len(nums) 4 target = int(input()) # taking a target value as int ValueError: invalid literal for int() with base 10: '2 7 11 10'