nonetype

Why is this list becoming NoneType when a recursion happens?

Why is this list becoming NoneType when a recursion happens? Question: so im trying to make this code which finds if there is a subset of numbers in a list which sum up to a result which is also passed in. Whenever I run my code however for some reason my currentlist variable becomes NoneType. …

Total answers: 1

AttributeError: 'NoneType' object has no attribute 'dtypes'

AttributeError: 'NoneType' object has no attribute 'dtypes' Question: I am trying to sort a subset of my data frame in increasing order with respect to the date index. When I run the sort function only by specifying the axis the code runs. When I add inplace=True I get the error message: AttributeError Traceback (most recent …

Total answers: 2

How to deal with NoneType error in Python?

How to deal with NoneType error in Python? Question: I have only picked up coding and Python in the past week so this question may seem obvious. I am trying to create a card game. I have already created my deck of cards and now I’m trying to make a function to remove a card …

Total answers: 4

Round list values with list comprehension including None

Round list values with list comprehension including None Question: I want to round down values of a list ignoring None. Given a list without None values I would do it like: import math value_list = [1.5, 2.3, 3.2, 4.7] rounded_list = [math.floor(elem) for elem in value_list] A list including None values gives an error: import …

Total answers: 3

Lines of txt read as NoneType

Lines of txt read as NoneType Question: I am using python3 to open a text file in the current directory and read through all of the lines. Each line in test.txt is a path to an image. My objective is to get the path before the file extension (which works), but then when I try …

Total answers: 3

Failed geolocalization with Geopy, Nominatim: TypeError: 'NoneType' object is not subscriptable

Failed geolocalization with Geopy, Nominatim: TypeError: 'NoneType' object is not subscriptable Question: I am trying to use module Geopy, function Nominatim to geolocalize a list of addresses (contained inside a CSV file). Here is my code: import pandas as pd from geopy.geocoders import Nominatim df = pd.read_csv(‘incidenti genova 3.csv’, delimiter=’;’, error_bad_lines=False) indirizzi = df.descrizione_strada nom=Nominatim(user_agent="my-application") …

Total answers: 1

How to return a complete for Loop in a function

How to return a complete for Loop in a function Question: I’m trying to run a For loop in a function but when I call the function only the first value is returned. I’ve tried ending the loop with a print instead of a return, which gets the correct result (It prints every value in …

Total answers: 2

Collatz Sequence – getting a None at the end

Collatz Sequence – getting a None at the end Question: Learning from “Automate The Boring Stuff” by Al Sweigart. At the end of Chapter 3, the Collatz Sequence is given as practice. The output seems correct, but the last row has a ‘None’ in it. In the code below, I am guessing that when p …

Total answers: 1

None-type in script

None-type in script Question: I’m making a calculator that imports 2 unit files and calculates which one would win, and with what numbers left (have removed the tkinter stuffs as there wasn’t enough space in stack overflow to let me). I run the code, and get this: Exception in Tkinter callback Traceback (most recent call …

Total answers: 1

Python: None value when returning from function

Python: None value when returning from function Question: I’m writing a program that stores 3 players and their scores in a list and then prints them out at the end. Simple stuff really, however I’m trying to call the value for the player score from a function called playerscore() which prevents you from entering a …

Total answers: 4