[Solved] How can I turn this txt file to a pandas DataFrame?

As MrSmily2019 said you will want to use https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html. It does more than just CSV, it can do text. Additionally you can turn text files into csv. You file seems to be “TAB” delimited (how it know to separate) instead of comma. You can adjust the settings so it knows to do it on the … Read more

[Solved] I’m struggling to make the function work on my code. I’m missing the part where i want to print the letter grade

You need to adjust your showScores and printLetterGrade functions as follows: def showScores(grade1, grade2, grade3, grade4, grade5): print(“{} is {}”.format(grade1, printLetterGrade(grade1))) print(“{} is {}”.format(grade2, printLetterGrade(grade2))) print(“{} is {}”.format(grade3, printLetterGrade(grade3))) print(“{} is {}”.format(grade4, printLetterGrade(grade4))) print(“{} is {}”.format(grade5, printLetterGrade(grade5))) def printLetterGrade(grade): if (grade < 60): printLetterGrade = “F” elif (grade < 70): printLetterGrade =”D” elif (grade < … Read more

[Solved] Converting Python Script to C++ [closed]

When the class calls itself like that it’s the __call__ method in the class that it is calling, like operator(). __init__ is like a constructor and is called when the class is instantiated, so everything in init is available by the time the class gets to __call__. class ReducedMomentum: # here is where an instance … Read more

[Solved] defaultdict key default value issues

I am guessing, that the defaultdict is not what you want to use. Default values should be declared in the second argument of the get method. problem = [{‘lastInspection’: {‘date’: ‘2018-01-03’}, ‘contacts’: []}] default_inspection = { ‘date’: ‘2018-01-03’ } for p in problem: # default_inspection is returned, when ‘lastInspection’ is not present in the json … Read more

[Solved] how to stop a program in try/except [duplicate]

The bare except catches SystemExit so the sys.exit() call is prevented from causing the program from exiting. Move sys.exit() out of the try. Also I don’t like to see a bare except without a logging.exception(”) in it. 0 solved how to stop a program in try/except [duplicate]

[Solved] How can i use discordpy cooldown command for client = discord.Client() [closed]

Also client = discord.Client() will not work. Use client = commands.Bot(command_prefix=prefix, intents=intents) Cooldowns are only for commands. Put this under a command – @commands.command() or @client.command: @commands.cooldown(uses, cooldown_time, commands.BucketType.user) e.g. @commands.cooldown(1, 30, commands.BucketType.user) Source: Cooldown For Command On Discord Bot Python 1 use per user and cooldown time is 30s If you don’t want that. … Read more

[Solved] Discord.Py / Bot was working great at first. Now the bot is live but when I try to give a command, Nothing happens and it doesnt show any error

Discord.Py / Bot was working great at first. Now the bot is live but when I try to give a command, Nothing happens and it doesnt show any error solved Discord.Py / Bot was working great at first. Now the bot is live but when I try to give a command, Nothing happens and it … Read more

[Solved] Print statement only once in a while loop (Python, Selenium) [closed]

You just need to change the order of your code, and you don’t need an if..else statement. Let it default to “Checking availability…”, and then start your loop which will refresh the page every 45 seconds until that text you specified is gone from driver.page_source driver.get(“Link of product site.”) print(“Checking availability…”) while “Not available right … Read more

[Solved] obj.name() object is not callable [closed]

Learn Indentation a = int (input(“x”)) b = int (input (“y”)) c = int (input(“z “)) if a ==b==c: print (“all equal”) elif(a>b and a>c): print(“x is greatest”) elif(b>c and b>a): print(“y is greatest “) else : print(“z is greatest”) solved obj.name() object is not callable [closed]

[Solved] Python 3.x -> Find Last Occurrence of character in string by using recursion and loop

With iteration: def find_last(line,ch): last_seen =-1 for i in range(len(line)): if line[i] == ch: last_seen=i return last_seen With recursion: def find_last_rec(line,ch,count): if count==line(len)-1: return -1 elif line[count] ==ch: return max(count, find_last_rec(line,ch,count+1)) else: return find_last_rec(line,ch,count+1) def find_last(line,ch): return find_last_rec(line,ch,0) solved Python 3.x -> Find Last Occurrence of character in string by using recursion and loop