Answer to Question #263967 in Python for Isabel Cortez

Question #263967

4. What's in There?

by CodeChum Admin



Instructions:

  1. Create a variable that accepts a positive integer.
  2. Create an empty list. Then, using loops, add string values to your list using the input() function. The number of string values to be added are dependent on the inputted value on the first inputted integer.
  3. Create another variable that accepts a non-negative integer. The number must only range from 0 until the value of the first inputted integer.
  4. Using your understanding on accessing list elements, access and print out the list element having the index position of the second inputted integer.



Input

The first line contains an integer n which is the size of the array.

The next n lines contains a string on each.

The last line contains an integer which is the index to be accessed and printed.

6
Learning
Programming
made
easy
with
Cody!
5



Output

A line containing a string.

Cody!
1
Expert's answer
2021-11-10T06:33:26-0500
#Getting an integer as an length of the list
n = int(input("Enter an integer, please: "))


#Creating an empty list to append the data of the user
list_1 = []


#Getting an input using a for loop and number of input is dependent on the variable n
for i in range(n):
  element = input("")
  list_1.append(element)


#Getting an input of the element to be printed
element_wanted = int(input("Enter the index of the element you want: "))


print("The element you want is: ", list_1[element_wanted])

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS