Корзина с фруктами, задача под замком не работает, подскажиие | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Корзина с фруктами, задача под замком не работает, подскажиие

fruits = ["apple", "cherry", "banana", "kiwi", "lemon", "pear", "peach", "avocado"] num = int(input()) # место для вашего кода if num <= 0 or num <= 7: print(fruits[num]) else: print("Wrong number")

25th Feb 2021, 10:38 AM
Егор Осмоловский
Егор Осмоловский - avatar
3 Answers
+ 2
Егор Осмоловский Yes but for example if the input is 10, it will still evaluate to True even though it is not between 0 and 7. Да, но, например, если ввод равен 10, он все равно будет оцениваться как True, даже если он не находится между 0 и 7. (n > 0 or n < 7) (True or False) ---> True 👍
25th Feb 2021, 11:10 AM
noteve
noteve - avatar
+ 1
if num >= 0 and num <= 7: print(fruits[num]) # Change 'or' to 'and' # Change <= to >=
25th Feb 2021, 10:46 AM
noteve
noteve - avatar
+ 1
In task :If n< 0 or n>7 (the index of last fruit ), program outputs "Wrong number". Пример ввода: 2 Пример вывода: banana This confuse me... I belive We need to do with "or" When i do first Time that looks Like' If num == 0: print (fruits[0]) .... :) But python about simple way)
25th Feb 2021, 11:04 AM
Егор Осмоловский
Егор Осмоловский - avatar