error-handling

How to handle non-generic errors in python?

How to handle non-generic errors in python? Question: I have a loop that I run via the statement: os.system(‘python3 wrapper.py’) which generates some files. And every so often it hits an error such as this: pybullet.error: Cannot load URDF file. Error: InMemoryFile::~InMemoryFileIO (numAllocs 1 numFrees 2 This message is printed to the terminal. I would …

Total answers: 1

can only join an iterable error on shell scrapy on python scraping

can only join an iterable error on shell scrapy on python scraping Question: I have a simply code for scrapy but i got an error when there is None, see my code below, how can fix it In [428]: ”.join(response.css(".prdd-price-first::text").get()).strip() TypeError: can only join an iterable Asked By: crawlers || Source Answers: Iterable means your …

Total answers: 1

target = []: ^ IndentationError: expected an indented block after 'if' statement on line 156

target = []: ^ IndentationError: expected an indented block after 'if' statement on line 156 Question: Thats the code where the mistake is if tool == ("11"): target = []: with open(‘freesec.txt’,’r’) as f: for line in f: url = str(line.replace(‘n’,”)) targets.append(url) for url in targets: if ‘http://’ in url: url = url.replace(‘http://’, ”) elif …

Total answers: 1

Why is Try Block of code not counting the same as when I don't use Try?

Why is Try Block of code not counting the same as when I don't use Try? Question: I have a function that pulls data from a Restaurant’s Clover POS System, then returns dictionaries with how many of each item was sold and then how many of each modification was made (ex: "Remove Nutella":5) My problem …

Total answers: 1

Rerun code if file doesn't exist is not working

Rerun code if file doesn't exist is not working Question: I have this code to read a file def collect_exp_data(file_name): data = dict() while True: try: with open(file_name, ‘r’) as h: break for line in h: batch, x, y, value = line.split(‘,’) try: if not batch in data: data[batch] = [] data[batch] += [(float(x), float(y), …

Total answers: 3

Python ValueError is it possible to get the Incorrect Value without string parsing?

Python ValueError is it possible to get the Incorrect Value without string parsing? Question: I have this bit of code : while True: try: start = int(input("Starting number: ")) fin = int(input("Ending number: ")) amount = int(input("Count by: ")) except ValueError as verr: print(‘error : ‘, verr,’n restarting ….’) else: break I would like to …

Total answers: 4

Python return list not working for some reason

Python return list not working for some reason Question: I’ve been trying to work on this assignment but for some reason the function I wrote won’t return the list I specified and throws a name ‘numbers’ is not defined error at me when printing the list outside the function. def inputNumbers(): try: initial_number_input = int(input("Please …

Total answers: 2

How to fix "During handling of the above exception, another exception occurred: "

How to fix "During handling of the above exception, another exception occurred: " Question: How do i fix this error, whenever i enter data that should cause an exception more than once the program crashes. Here is my code and what it outputs, it should keep repeating until correct data is entered. code flag=False while …

Total answers: 1

'NoneType' object is not subscriptable in list when expanding

'NoneType' object is not subscriptable in list when expanding Question: Hi guys i need help im doin my personal project and i dont know how to move from this error and make the f…ing list subscriptable. k = int(input("Počet políčok s pohyblivým pieskom: ")) *#This is basically input for down bellow thingy* if k >= …

Total answers: 1

Resource punkt not found. Please use the NLTK Downloader to obtain the resource: >>> import nltk >>> nltk.download('punkt')

Resource punkt not found. Please use the NLTK Downloader to obtain the resource: >>> import nltk >>> nltk.download('punkt') Question: I have NLTK installed and it is going me error Resource punkt not found. Please use the NLTK Downloader to obtain the resource: import nltk nltk.download(‘punkt’) For more information see: https://www.nltk.org/data.html Attempted to load tokenizers/punkt/PY3/english.pickle Searched …

Total answers: 4