user-input

Unable to retrieve variable assigned in function

Unable to retrieve variable assigned in function Question: I am writing a function where it gets input from the user and sets the variable answer to the answer the user gives. I am printing answer outside of the function, but for some reason, it doesn’t print anything. answer = " " # set empty in …

Total answers: 2

How to repeat the input until a special condition is met in Python?

How to repeat the input until a special condition is met in Python? Question: I need to take integer inputs from the user and add them to a set. The number of integers is unknown. The input process will end when the user input is "Done". Here is my code: s = set() print(‘Please type …

Total answers: 5

Delete a dict from a list based on one value provided by user input – python

Delete a dict from a list based on one value provided by user input – python Question: I have the initial code: books = [] def add_book(): name = input(‘Input the name of the book: ‘) author = input(‘Input the author: ‘) print(‘Book added successfully.’) books.append( { ‘name’: name, ‘author’: author, ‘read’: False } ) …

Total answers: 3

How to web scrape from youtube using Selenium and Python

How to web scrape from youtube using Selenium and Python Question: Code trilas: from selenium import webdriver from selenium.webdriver.chrome.options import Options import time import json options = Options() options.headless = False driver = webdriver.Chrome(options=options) //used to choose options from chrome// driver.implicitly_wait(5) baseurl = ‘http://youtube.com’ keyword = input() #user input as earth driver.get(f'{baseurl}/search?q= {keyword}’) I want …

Total answers: 1

How to fix 'RuntimeError: input(): lost sys.stdin' error in python 3.7

How to fix 'RuntimeError: input(): lost sys.stdin' error in python 3.7 Question: I am practicing some codes and seemingly out of nowhere i have got this error when I ran a very usual piece of code. The problem i am solving takes input, calculates something and gives an output. I was running it on an …

Total answers: 8

Jupyter notebook: let a user inputs a drawing

Jupyter notebook: let a user inputs a drawing Question: Simple question but I’m not able to find something out there… Is there a simple and user friendly tool that can be used within a jupyter-notebook to let the user draw something in black on a white space (let say of size (x,y) pixels) after running …

Total answers: 3

How convert user inputted constant (pi,e) to float in python?

How convert user inputted constant (pi,e) to float in python? Question: I’m writing a code which must compute definite integral of a function. I’ll provide code in the below. How can I urge computer to understand user input “pi” or “e” for constant numbers? Problem is that I must convert the type of input to …

Total answers: 2

How can I limit the user input to only integers in Python

How can I limit the user input to only integers in Python Question: I’m trying to make a multiple choice survey that allows the user to pick from options 1-x. How can I make it so that if the user enters any characters besides numbers, return something like "That’s an invalid answer" def Survey(): print(‘1) …

Total answers: 7