while-loop

Using Exception Handling in Python

Using Exception Handling in Python Question: Using exception handling inside a loop in python, I’m receiving inputs from a user and adds it to a list but if the user types ‘done’ the loop terminates and sums up the list. If the user types any other non numeric data it would print ‘Wrong Data’ and …

Total answers: 1

How to for-while loop using function variable values?

How to for-while loop using function variable values? Question: I’m trying to build a for-loop based on function varbiables values. I have this code: import yagooglesearch query = "future" #something to google-search client = yagooglesearch.SearchClient( query, start=0, num=100, #number of result that i want for each loop (100 is the max) max_search_result_urls_to_return=500, #total number of …

Total answers: 1

Python matplotlib loop not showing anything

Python matplotlib loop not showing anything Question: I’m trying to make a graph that should update periodically using a while loop. This is the code: import matplotlib.pyplot as plt import numpy as np import time fig = plt.figure() while True: data_to_plot = pd.DataFrame(predictions) data_to_plot.columns = [‘A’,’B’,’C’] data_to_plot.plot() plt.pause(10) fig.canvas.draw() fig.canvas.flush_events() What it does is just …

Total answers: 1

How to make the loop continue even after a part of it breaks in python

How to make the loop continue even after a part of it breaks in python Question: The code below ends after a player has reached a value of 20. What I tried to code (but failed) was that if a player (say player 1) reaches 20 it stops that player’s part of code and keeps …

Total answers: 3

Why does my while loop calculate incorrect value of the string?

Why does my while loop calculate incorrect value of the string? Question: I am trying to find greatest length of a word from the string return it by using values of each letter from alphabets by assigning each letter it’s value as per it’s rank . So for example For a string s = ‘abcd …

Total answers: 3