syntax

using and vs or in statments

using and vs or in statments Question: while gender.capitalize() != "M" and gender.capitalize() != "F" and gender.capitalize() != "Male" and gender.capitalize() != "Female": print("Not a valid entry: ") gender = (input("Gender: ")) if gender.capitalize() == "M" or gender.capitalize()== "Male": print("Hello " + name + " you are " + age + " years old and …

Total answers: 2

Syntax error in dictionary with multiple values in a single key

Syntax error in dictionary with multiple values in a single key Question: I am learning about dictionaries in Python and creating multiple values inside a single key. I have followed his instructions (from 2016) to a T, and even compared our code 1 to 1 and it is exact – yet mine yields a syntax …

Total answers: 2

python script opening multiple terminals, but only executing command in one

python script opening multiple terminals, but only executing command in one Question: I’d like my script to open 3 terminals and execute different commands in each, but all it does is run an nmap scan in the original terminal and opens 3 blank terminals. import subprocess TARGET_IP_ADDRESS = "IPHERE" terminal_windows = [] for i in …

Total answers: 1

python password generator loop problem print error

python password generator loop problem print error Question: I trying to make a password generator using python. Currently, I just want the program to print random characters from the ascii table. I will later introduce numbers and symbols. I used a for loop to print random character from a range that the user inputs. It …

Total answers: 4

Hi, New to coding and cant seem to find the solution for this error (Python)

Hi, New to coding and cant seem to find the solution for this error (Python) Question: text = ["this","is","text"] print(f"hello and {text, end=","}") Input In [58] print(f"hello and {text, end=","}") ^ SyntaxError: f-string: expecting ‘}’ I am trying to remove brackets and commas while using an f string …………………… Asked By: Passiv AHS || Source …

Total answers: 1

Why does my python code run perfectly fine on runestone but not on vscode?

Why does my python code run perfectly fine on runestone but not on vscode? Question: def CreditPay(rate, payment, verbose): balance = 1000 # Amount currently owed month = 1 #Number of months paid = 0 # Amount paid so far while balance > payment: balance = balance + balance*rate/100 – payment paid += payment if …

Total answers: 2

How to find duplicates in list of lists?

How to find duplicates in list of lists? Question: I have a list of key binds in a class like so: self.key_bind_list = [["A", "B"], ["C"], ["SHIFT", "NUM6", "NUM7"], ["A", "B"], ["A", "B", "C"]] *in this case a duplicate should be detected by the sublists ["A", "B"], but not by ["A", "B"] and ["A", "B", …

Total answers: 3

Having problems running script getting error: if event.type == pygame.QUIT: syntax Error

Having problems running script getting error: if event.type == pygame.QUIT: syntax Error Question: So I’m following this tutorial: https://www.youtube.com/watch?v=Vg83OtRkevE and I’ve done everything the tutorial told me to but I’m still getting this error message when I run it: if event.type == pygame.QUIT: syntax Error (this was made in repl.it) my code is: import sys …

Total answers: 1

Python if statement inside for loop

Python if statement inside for loop Question: I’m expecting to get "is null", because var0 is equal zero and the if statement shall print is null! Is is a syntax mistake? var0 = 0 var1 = 1 var2 = 2 for i in range(3): if f"var{i}" == 0: print("is null") I’m not getting any output. …

Total answers: 3

Assigning "None" to a function that requires transfer parameters (Python)

Assigning "None" to a function that requires transfer parameters (Python) Question: I’m struggling at assigning "None" values to all parameter of a function. for i in range(18): sx.set_attribute(v{i}=None) The attributes I want to fill with "None" are v0 -> v18 I’m only looking for the right syntax. If you know a better way to assign …

Total answers: 1