We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
that is list comprehension
the varriable "arr" takes two inputs, but the second input is placed inside the float function, so the input is converted to a floating point value,which means it cant take strings,then "for _ in range(input())", the "_" can be replaced with anything, its just that if you are writing code where you wont need to use that particular variable for anything, you could call it _, its just a community rule of thum thingy,so the third input is taken at the point of the range, its just a way of reducing the amount of code one has to write, so instead of doing something like,
a=raw_input()b=float(raw_input())d=input()arr=[a,b]for_inrange(d):# you can use i or any variable name in place of '_'c=sorted(set([bfora,binarr]))[1]# the 1 in braces means the order in which the sorting should be done, if you use -1 it will be in reverse order
you just use the short version you have there
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Nested Lists
You are viewing a single comment's thread. Return to all comments →
that is list comprehension the varriable "arr" takes two inputs, but the second input is placed inside the float function, so the input is converted to a floating point value,which means it cant take strings,then "for _ in range(input())", the "_" can be replaced with anything, its just that if you are writing code where you wont need to use that particular variable for anything, you could call it _, its just a community rule of thum thingy,so the third input is taken at the point of the range, its just a way of reducing the amount of code one has to write, so instead of doing something like,
you just use the short version you have there