Skip to content
Advertisement

Tag: python

Python for-loop jumps over the second element of a list

The for loop is supposed to go through a list and add the elements to another list until it encounters an empty string. However, it keeps jumping over the second element. The for-loop is supposed to go through a list(“baa”), adding every element to a different list(“foo”), until it encounters an empty string. At that point it is supposed to

Is there a way to mimic the pipe operator from R in Python?

See the example below. Is it possible to put each Python operation on a new line? If I have many operations, the code is not all visible. I need to scroll the VS Code window to the right. Thanks Answer In Python, line breaks inside parentheses are ignored, so you could rewrite as: This post may be helpful.

Loops in Python

Total Python newbie/noob here. I have to write a code that asks the user to input 3 or more company names. If a) the company has already been entered, a new name should be asked and b) if the company does not exists (I have a dozen of so csv files from company shares), a new one should be asked

Selecting columns from CSV file

Python newbie here. I have a bunch of CSV files of stock prices. They are structured as date, opening, high, low, close, adj. close, volume. I only need the date (column 1), the opening (column 2) and close (column 5). The task prohibits the use of pandas. How can I extract those three columns and return them? This is my

Advertisement