26.1k views
1 vote
Write an expression to print each price in stock prices.

Sample output with inputs:
34.62
76.30
85.05
# NOTE: The following statement converts the input into a list container 2 stock_prices - input().split() 5 4 for "solution goes here": print('s', price) Run TL

User SevenDays
by
3.9k points

1 Answer

6 votes

Answer:

The program written in python is as follows

prices = "34.62 76.30 85.05"

stock_prices = prices.split()

for price in stock_prices:

print('s', price)

Step-by-step explanation:

This line initialized the input prices using a string variable named prices

prices = "34.62 76.30 85.05"

This line converts prices to list

stock_prices = prices.split()

The following iteration prints each element of the list

for price in stock_prices:

print('s', price)

User Joey Trang
by
4.3k points