0

I'm trying to print out a cell in sqlite as f string, to use it outside of database. I'm get this printout when program is running:

Please select what calculation you want perform '+', '-', '/', '*' or 'change calculation method' + Invalid input: 'NoneType' object is not iterable please enter a new number

I have been trying with different methods without success, I cannot convert None to f string.

My program:

class GameTracking:
    def __init__(self):
        self.view_name()

    def view(self):
        for row in database_input.view():
            extracted_name = print(type(row))
            print(str(f"Hey {extracted_name} selected correct"))
            print(str(extracted_name.__str__()))
                  
    def view_name(self):
        """
        Displaying name of player as f string
        """
        self.view() # display name as f string in print statement maybe fetch name for another file -> tracking of name and score
lemon
  • 14,875
  • 6
  • 18
  • 38
Hawkeye
  • 1
  • 2
  • Does this answer your question? [Transform string to f-string](https://stackoverflow.com/questions/44757222/transform-string-to-f-string) – Zain Ul Abidin Aug 03 '22 at 13:32
  • Please include your entire error message and traceback. – Steven Rumbalski Aug 03 '22 at 13:34
  • 1
    Note that in this line `extracted_name = print(type(row))` the print function returns `None` and it gets assigned to `extracted_name`. That said, a value of `None` will work just fine with your f-string. – Steven Rumbalski Aug 03 '22 at 13:36
  • Im only get this printout: please select what calculation you want perform '+', '-', '/', '*' or 'change calculation please select what calculation you want perform '+', '-', '/', '*' or 'change calculation method' + Hey None selected correct None program seems does not crash – Hawkeye Aug 03 '22 at 14:01
  • @Hawkeye: Please edit your question with enough information to duplicate your error. One thing I notice is your comment doesn't match your question. Your question has "Invalid input: 'NoneType' object is not iterable" but your comment has "Invalid input: unbound method str.format() needs an argument". – Steven Rumbalski Aug 03 '22 at 14:11
  • Just a as extra Info I has saved Tg -> my playername to database and – Hawkeye Aug 03 '22 at 14:12
  • @StevenRumbalski sorry for that it was a copy error mistake, its correct now – Hawkeye Aug 03 '22 at 14:13
  • Your question in its current form does not have enough information to be answerable and as such I am voting to close it. Please review [How do I ask a good question](https://stackoverflow.com/help/how-to-ask). – Steven Rumbalski Aug 03 '22 at 14:14
  • @StevenRumbalski I agree with you, I need to rethink of my question to solve this, Im newbie here, thanks for the link to about how ask question :-) – Hawkeye Aug 03 '22 at 14:23

1 Answers1

0

I managed to solve the problem :-)

Since this player name was imported from another a file and some part was not included from start when I wrote the question, due to I was thinking it was not needed.

Here is my solution :-) It was only needed to get the "return rows" to printout file to make it to work. :-)

From database file:

def view(self):
    self.cur.execute("SELECT first_name FROM book ORDER BY id DESC LIMIT 1")
    rows = self.cur.fetchone()
    return rows

From printout file:

from UserAccoutDetailsBackEndOOP import Database_input
import GameTrackingBackEndOOP as rows
database_input = Database_input("accountdetails.db")
view = Database_input

class GameTracking:
def __init__(self):
    self.view_name()

def view(self):
    extracted_name = rows 
    for extracted_name in database_input.view():
        print (str(f"Hey {extracted_name} selected correct"))
           
def view_name(self):
    """
    Displaying name of player as f string
    """
    self.view() # display name as f string in print statement maybe fetch name for another file -> tracking of name and score

And result is: (TG is playername from sqlite database)

  please select what calculation you want perform '+',  '-', '/', '*' or 
 'change calculation method' +
  Hey Tg selected correct
Hawkeye
  • 1
  • 2