mardi 26 octobre 2021

while loop continues without reassigning variable with input [closed]

In my Python infancy I am attempting a self directed project where I hit an API for stock data and eventually organize it into orderly tables for analysis. However, I cannot quite get the method to work that selects the data. I have attempted to create a while loop that checks the existence of stock tickers and loads them into a list but the loop will check the first ticker input and then rush through the code again and plug an empty value into the ticker variable and run again. I don't understand why its not waiting for input again.

def loadticks(self):
    add = True
    while add:
        newtick = input('What tickers do you want to look at? When you decide you\'ve added enough you can type DONE \n')
        if newtick == 'DONE':
            add = False
        else:
            self.getset(newtick)
            if self.tickcheck(newtick):
                print(f'Okay I added {newtick} to the list.')
                self.ticks.append(newtick)
            else:
                print('That ticker is no good.')

Aucun commentaire:

Enregistrer un commentaire