You can achive this through using join(), split() + list of censors words. You code like be userText = input("Enter some Text to be Censored: ") # Initialization of censors words list and replaced by censors_words = ['dang', 'darn', 'freak']...
Look closely at your code: while True: ... result+=term k=+1 ^^ || return result That assigns +1 to k I suspect you wanted this: while True: ... result+=term k+=1 ...
Quote: I am getting indentation in this basic code in Python can someone explain this ? Did you forgot the word 'Error' ? Try import cmath a = 1 b = 5 c = 6 # calculate the discriminant d = (b**2) - (4*a*c) if d > 0: sol1 =...
Richard's comment to you is more important than you might think. Suppose we do the work for you, and write the code for you, what would you actually learn from this? You certainly wouldn't have learned the thought process behind how we would...
There is a pretty big clue in what your teacher gave you: # Hint: Type return a+b below Literally all you have to do is remove the "# Hint: Type " and "below" bits and it'll work... You are never going to pass this course unless you read carefully, and start thinking ... honest!
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us...
Very Clear, some of your lines in code don't have valid float data. Best way to find the error is implement exception handling in your code. Python Exception Handling Using try, except and finally statement[^] Or print some log/message to find...
Because this test always passes: if line == "done" or "Done": because in Python any non-empty string is True and the second part of your condition is just a string literal. Change it to this: if line == "done" or line == "Done": and it'll get to...
First, you don't have to specify an else if there's nothing to do outside of the conditions you've been given. Next, the program spec says Quote: Write a function giving the sum of the integers of [1,N] divisible by 3 or 5. You might want to...
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action. Try it yourself, you may find it is...
The second loop tries to repeat for the range (2,2) in the first iteration. Which is effectively while x is greater than 2 and less than 2: but that is impossible so the loop terminates. So the output starts at 3 which is the next iteration of the outer loop when n has a value of 3. If you look...
Quote: Code is ready and working, but GIT shows incorrect as far as I can see, your usage of 3 spaces as indentation is perfectly legal, but Git want 4 spaces. "indentation is not a multiple of four"
Sure, I can just give you a full blowup solution, but I am not sure you will learn something. As it is very basic understanding of Python and programming, I think it is better to give you leads and a link to a good tutorial. # Because of print(dec_to_binary(145)) # -> 10010001 # and ...
Try the following. You may need to modify some part of it to meet your own criteria, but it does the basics. def binary_to_dec(binary: str) -> int: """ Uses the ord() builtin to get the numeric value of a character Subtracting the ord('0') gets the integer value of the digit ...
You forgot the parentheses in your call to create an instance of the class Laptop. It should be: class student : def __init__(self,name,rno) : self.name=name self.rno=rno self.Lap=self.Laptop() #
First a typo: "But the answer is 49, which means 7*7" Quote: I'm trying to compute the nearest square of a number less than a limit using python. If limit is 36, which answer do you expect 25 or 36 ? Quote: It works, the output answer is 36. But I'm still a little bit confused about the...
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us...
Of course it does, as you are passing parameters by position and not by name. So if you reverse the order in line 12 then they will be reversed when they are received by c1's constructor. If you want the values to be referred to by name then your...
Apart for not compiling as is, so the code sample you show won't work, give it a try: replace the "if" with a print statement and show the values of i and j. Whichever goes up first is the inner loop.
Using a simple example we get the equivalent shown here: x = [ 2, 3, 4, 7, 11 ] z = [j for i in x for j in range(len(x)) if i == x[j]] print(z) # which is the same as zzz = [] for i in x: for j in range(len(x)): ...
Why do you think? What would change if you didn't? Do two things: 1) Read this: Binary search algorithm - Wikipedia[^] And 2) Break out the debugger and follow your code through as is. Now change "m + 1" to "m" and try it again. What changed?...
The same answer as you were given four days ago at https://www.codeproject.com/Questions/5279256/Why-do-we-add-1-to-the-r-plus-m-in-the-last-line[^]. Did you follow the suggestions?
Same question as Why do we add 1 to the r + m in the last line ?[^] with mostly same code. m+1 is not alone it foes with other variables: elif lst [ m] > key : return bsearch2 ( lst , key , lo , m ) else : # lst[m]
Quote: can anyone give me the best approach to this question?? Read through the instructions to see what classes of objects you need to create. The first item in the instructions is a state, which contains some number of cities. So you need a...
In Python indentation is significant: identically indented lines of code form a block of code which is executed together. So when you do an if ... else statement, all teh lines that are executed when the condition is true must share teh same...
Complex math takes care of the discriminant sign, so you may write import cmath sol1 = (-b-cmath.sqrt(d))/(2*a) sol2 = (-b+cmath.sqrt(d))/(2*a) print('The Solutions are {0} and {1}'.format(sol1, sol2)) Using the traditional ('real' math)...
from "The Code Conversion Service": :-) #include using namespace std; string caesar( string message, int shift) { string result; for (auto c : message) { if ( c >= 'a' && c
Quote: i tried but failed to get answer. The help you want is us to do the job. You show no attempt to solve the problem yourself, you have no question, your main effort is pasting the requirement, you just want us to do your HomeWork....
Start by learning Python: it is an unusual language in that indentation is significant - it determines what code is part of what. So when you create a function, all the code in the body of the function must be indented to the same level (or...
Start by looking closely at each question. a. refactor the script into a function, get_grades() - so you need to create a function which returns a dictionary: def get_grades(): grades = {} # declare an empty dictionary # add the code...
+You get an error because the function requires at least two parameters, num1 and num2 Since you provide only one, the system can't call the function and raises an error instead.
Read the error message, it is pretty clear: File "C:/Users/user/Desktop/car dealer/car dealer.py", line 505, in Add_car self.insert_photo = self.convert_image_into_binary(photo) NameError: name 'photo' is not defined So it's line 505, in...
vr20222, It's much simpler that what you have produced... my_keys = {"id","tiCustomField_CDP Neighbors"} res = {} l = [] for i in y: res = {my_key:i[my_key] for my_key in my_keys} l.append(res) print(l) You'll note that I reversed...
Your code is unreadable: when you paste code, you need to use the "Paste as" option "Code Block", or use the codewidget on the toolbar above the text box. That tells the system that characters are part of your code and shouldn't be...
The map() function[^] returns an iterator and you must convert it to a list before you can serialize it. return JsonResponse(list(sw_list), safe=False)
Never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Always use Parameterized queries instead. When you concatenate strings, you cause...
In general, there is no way for software to destroy the motherboard it is running on: this is considered as a design feature as it prevents malicious morons from releasing software which does just that to unsuspecting users ...
Never expected that you like to do that what @OriginalGriff brings up. In that case, even it is not programmatically I suggest a screwdriver, maybe there is a Python version of it.... Btw. I could not resist, down votes expected ;p
JSON isn't a database: That's not a database, dude![^] To "merge" JSON files, they all need to be using the same data structure (not guaranteed) and require you to either load the JSON data into python classes and merge those before generating a...
You're making a GET request to the delete_image route, using an tag, so you won't be able to include hidden fields in the request. But endpoints which create, change, or delete data should never accept GET requests. Some browsers or...
Neither of your distance or area functions return a value:, but the code calling the functions expects them to. See here: Python Function Return Value[^] and try this: import math def distance (x1,y1,x2,y2): horizontal=x2-x1 ...
Yes because unless the first character in the word matches the letter, the while loop will continue until the end of time. I don't expect you want to wait that long. You need to increment the index in your while loop each time you test a...
Quote: The following program does not run. Please don't ask me to debug the code myself. I am unable to. Which means "I found this on the internet, and I can't be bothered to work out how it works - so fix it for me" without telling us anything...
Richard already gave you the correct solution. As an alternative, you may use the count method of the string type: number = "mississippi".count("s") print('There are', number, '"s" characters')
In the current functionality, the function find is intended to find the index of a particular letter in a given word. To count the number of occurrences of a letter in a given word, you can modify the find function to iterate through the entire...
"It doesn't work" is probably the most useless problem report we get - and we get it a lot. It tells us nothing about what is happening, or when it happens - and "I get error" means just that - "it doesn;t work"! So tell us what it is doing that...
Quote: i dont know what to write in the else part First, you have to fix your ifcondition. As suggested, look again at the requirement. See if your code complies. The else part is optional, if you don't need it, then omit it.
Here is the sample code snippet - conn = httplib.HTTPConnection("proxy_IP",proxy_port) conn.set_tunnel(host,80) conn.request("POST", parameter1, parameter2, parameter3) response = conn.getresponse() I am trying to tunnel the web request sent to my host through a proxy server. The problem is,...
I have compatibility openpyxl and pyxlsb, using openpyxlI have done some code to style the cells accordingly but I need to compress the code or just avoid nested for loops or itertools. For following requirements I have tried code: What I have tried: 1) Here for 1st row i need to get...
Hello, Basically currently my program reads the Data file (electric info), sums the values up, and after summing the values, it changes all the negative numbers to 0, and keeps the positive numbers as they are. The program does this perfectly. This is the code I currently have: import csv from...
Not sure I understand the issue. But once you have done the first set of calculations you can read the datafile and do the cumulative calculations. Once you have those you can then write out the new data.
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action. Try it yourself, you may find it is...
Quote: i dont know how to do it. It start to be a rather advanced project (for school), but still simple for a professional programmer. You can't just "don't know how to do it" or be confused, or there is a problem in the course you follow, you may have to speak with your teacher. Programming...
I've tried two loops samples but ı didint understand why when"loop1" starts from "3", "loop2" starts from "2"? ı supposed that both should have been the same. Here is the output: 3 prime 4 = 2 * 2.0 5 prime 2 prime 3 prime 4 = 2 * 2.0 5 prime What I have tried: def...
A problem in your code is that you are guessing that you will values both over and under zero. max=0 min=0 What if all values are between 10 and 100 ? you need to initialize min and max with the first random value.
I'm getting "Unhashable Type : Index" error in python code. i'm using python3 . Can you please help me to resolve this problem? code- df_temp_cns = pd.read_excel(r"/nsmnt/NS_Exec_DSHBD/IS_IT_Demad_Perf/cns_weekly/SrcFile/JnJ_CNS_Weekly_No_Indication_WE_2019-01-25.xlsx", header=0,...
I am executing one code with speech recognition python library....then after run it comes say "Please build and install the PortAudio Python bindings first". then i install pyaudio library but same error comes. What I have tried: `r = sr.Recognizer() with sr.Microphone() as source: ...
We have no idea what data you provide to get the error, what the error is, what teh answer should be, ... anything at all really! So, it's going to be up to you. Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. How you use it depends on...
Hello guys, I have a problem with the following: I testing Python with selenium web driver. I need download data of different web page, the schema is the same in all pages, the difference is in the URL, since the last value is variable, it can be a number between 1 and 100. These URLs are...
I'm trying to merge the object based on key specs, most of the keys structure is consistent, taking into consideration the merge will only happen if company_name is the same (in this example, I only have one company_name) and if only (name, {color, type, license, description) are equal across...
def solveMeFirst(a,b): # Hint: Type return a+b below num1 = int(input()) num2 = int(input()) res = solveMeFirst(num1,num2) print(res) What I have tried: i have tried to run it and it is showing this error num1 = int(input()) ^ IndentationError: expected an indented block I am...
The solveMeFirst method is empty (a comment does not count as "code"). Therefore, Python's thinking is "there still has to be code" and the next code it notices, is not indented as per Python's indentation rules. So, put some code in the function. In fact, the comment tells you exactly what to...
' = ' this is used for assignment operator,, but you need ' == ' for comparison .. thats why it show an invalid syntax error .. and check you ' code indentation '
' = ' this is used for assignment operator,, but you need ' == ' for comparison .. thats why it show an invalid syntax error .. and check you ' code indentation
I wanted to copy the content of one docx/document to another docx/document at particular position. Note: Content might be having text data with background color, tables, smartart and images. What I have tried: def add_para_data(output_doc_name, paragraph): """ Write the run to the...
I have made a program, which calculates the area of Circle, Square and Triangle. The code is working if i press "run" command in Pychram. But when i upload it to git i get an email, that shows, the code is completely incorrect. The code: """Ask user a shape and a radius or a side length and...
I need to convert decimals to binary and binary to decimals but i get all the time wrong answers. I am not allowed to use bin and other built in statements in Pycharm that could help me to convert answer. """Converter.""" def dec_to_binary(dec: int) -> str: """ Convert decimal number...
I have a data frame, with students ID and names and other information. I have done a groupby on students ID, I need to create zip file(on student name) for each student and then zip them all. I have the following code. I can zip all the csvs, but how can I zip each individually first since...
We have been give a problem to add two numbers without the + operator and using XOR, AND and from sys import stdin,stdout T = int(stdin.readline().strip()) for itr_t in range(T): ...
I have an (20x4) ndarray and i need to rotate every 4 rows from beginning to form a new ndarray which has size of (5x16). For simplicity, here is a sample of the original data and the intended resulting data with random contents just to infer the way of transpose: original ndaaray: 0 1 2 ...
You don't need to pass self to a function: it's there in all classes automatically - it's the current instance of the class that contains the function. Think of it like cars: all cars have a glove box, so you could write a function to add or remove an item from it - but you don't need to pass...
I already finish the task, just need an explanation. I'm trying to compute the nearest square of a number less than a limit using python. Let's say if my limit is 40, then the nearest square would be 36 (from 6*6). What I have tried: I already found the answer, but need some explanation : ...
import requests from bs4 import BeautifulSoup import re import json def lol(url): with requests.Session() as req: r = req.get(url) soup = BeautifulSoup(r.content, 'html.parser') vs =...
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us...
Hello Everyone! I recently started with Django and I found a project on GitHub and I downloaded it and started working on it but it was created with Django version 1.4.2 is there any way to upgrade the whole project in the new version of Django...
Django 1.4 release last term support ended with october 2015. See: Download Django | Django[^] You have to update your code accrodingly to the current version of Django installed on your OS. Quote: I have tried to modify the files manually...
File "", line 37 sql_create_projects_table = CREATE TABLE IF NOT EXISTS ACTOR { ^ SyntaxError: invalid syntax when I write: sql_create_projects_table = CREATE...
class cl: def __init__(self,x,y): self.x = x self.y = y def multiply(self,n): self.x = self.x * n self.y = self.y * n class Cam(cl): def __init__(self,g,x,y): self.g = g ...