Kitten VS Puppy

Report a typo

The Kitten and his best friend Puppy are learning NumPy. They have learned a lot about boolean operations and decided to solve this task on Hyperskill. Unfortunately, they have only managed to read the input. Help them finish the program!

You have three lines in the input:

  1. The first line contains integers separated by spaces.

  2. The second line contains some words.

  3. The third line contains some words.

Your task is to create 3 arrays from these inputs. They are guaranteed to be of the same length. Then, for each number in the first array, check if it is negative or not:

  • If it is non-negative (equal to 0 or greater), print the corresponding element from the second array.

  • If it is negative, print the corresponding element from the third array.

You can use np.where() for checking.

Sample Input 1:

5 -7 9
Kitten will win
Puppy won't lose

Sample Output 1:

Kitten
won't
win
Write a program in Python 3
import numpy as np

lst_1 = []
for i in input().split():
lst_1.append(int(i))
lst_2 = input().split()
lst_3 = input().split()

# finish the code here, help the Kitten and the Puppy!
___

Create a free account to access the full topic