These are my solutions, your mileage may vary.
Remember, no solution is wrong.
ip = int(input())
var = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
ans = [x for x in var if x < ip]
print(ans)
ip = input('Enter a string: ')
if ip == ip[::-1]:
print('String is palindrome')
else:
print('String is not palindrome')
def make_new_list(l):
new_list = [l[0], l[-1]]
return new_list
a = [11,2,3,4,0]
ans = make_new_list(a)
print(ans)
price_dictionary = {
"banana": 1.50,
"avocado": 0.99,
"htomato": 0.89,
"cherry": 3.00
}
key = input('Enter the fruit: ')
if key in price_dictionary:
print('Price is {}'.format(price_dictionary[key]))
else:
print('{} not found'.format(key))
Any doubts, leave in the comments section.