Most voted "python-3.x" questions
Python 3 is the latest version of the Python programming language and was formally released on December 3, 2008.
Learn more…3,274 questions
Sort by count of
-
0
votes1
answer75
viewsCustom function for the Sorted function in python 3.x
In python 2.x I can pass a custom function to Sorted function, how to do this in python 3.x? Basically convert the code below def numeric_compare(x, y): return x - y print(sorted([5, 2, 4, 1, 3],…
-
0
votes1
answer122
viewsHow can I replace an error with a print without terminating the program? Python 3
If I create a variable with an input that only receives integer numbers (int) and put other types of numbers or even letters, it will generate an error and the program will terminate. I was…
python-3.xasked 6 years, 9 months ago Os carros são como as lanchas 1 -
0
votes1
answer325
viewsModule requests is imported into IDLE, but not into Thonny (the IDE I use)
I installed the module requests by Terminal with sudo pip3 install requests (I am using Mac) and managed to import it through the Interactive shell without problems in IDLE. But when I try to import…
-
0
votes1
answer32
viewsCreate a Python 3 file
I want to build a Python 3 function, which takes as a parameter a name of a text file and creates a new file. txt, named double.txt, which is the copy of the first one. How do I do this?
python-3.xasked 6 years, 9 months ago Filipa Isidro 9 -
0
votes2
answers5228
viewsTypeerror: Calcularsalario() Missing 1 required positional argument: 'Title'
While trying to create a simple Python Code and I came across the following error in the method of calculating salary Typeerror: Calcularsalario() Missing 1 required positional argument: 'Title'…
-
0
votes1
answer73
viewsProblems with Opencv(python3 and ROS)
i am using ROS for a project in college, but when I try to use python 3 to call opencv, this problem occurs "Import: /opt/Ros/Kinetic/lib/python2.7/dist-Packages/cv2.so: Undefined Symbol:…
-
0
votes1
answer88
viewsError using np.concatenate
I’m doing a mergesort using numpy library. It turns out it’s giving error in the line "np.concatenate(result,left[i:])" there in the merge function. That is the mistake: /sorts/main.py", line 30, in…
-
0
votes1
answer849
viewsSwitch chained list pointers - python
I created a function to change the pointers of a chained list, the idea is very simple, change them and update the next element so that it does not lose the reference, only that the function is…
-
0
votes1
answer390
viewsHow to modify a list within a Python method?
Suppose I have the following method and the following list: def ModificaValores(Valores): dados = [6,5,4,3,2,1,0] Valores = dados Valores = [0,1,2,3,4,5,6] print(Valores) ModificaValores(Valores)…
-
0
votes1
answer47
viewsWhat problem can occur when retouching a value without having a variable to receive (Python)?
If I have a function that returns a value or True and False, but doesn’t have a variable to receive, this may cause some problem in the functioning of the code? Example: def Retorna(): return False…
-
0
votes1
answer52
viewsSecond command does not work
I was testing the conditions, but when I use one command and then another, the second one isn’t working. c=str(input('')) if c == '/tutorial': print('ok, como vc é um hacker vc hackea td por…
-
0
votes1
answer1153
viewsHow to verify the existence of a file and the number of lines written in Python?
How best to check whether the file is existing and the number of lines inside the file.
-
0
votes2
answers198
viewsInstallation Cartopy
I’m trying to install the cartopy library. But I’m not getting it. Can someone help me? I tried by pypi and returned the following error: C:\Users\Rafa>pip install cartopy Collecting cartopy…
-
0
votes1
answer164
viewsIntegrate Python language to websites. How?
Hello , :-) I am an apprentice in Python, and I have the following question: How can I start integrating the Python language into websites? If possible, what procedures should I follow?…
-
0
votes0
answers182
viewsDLL error:api-ms-win-crt-Runtime-L1-1-0.dll when running Python
After I finished installing Python on my computer, while running Python on my CMD appeared the following message I tried to reinstall Python more than 3 times didn’t work, also tried to download the…
python-3.xasked 7 years ago Arima_Kousei 1 -
0
votes1
answer34
viewsI’m having trouble printing database values
I am trying to print the 'ok' on the screen when it finds the value '3' inside one of the Keys of the database. >>> with dbm.open('data1.db','r') as user: user['0'] = '1' user['1'] = '2'…
python-3.xasked 7 years ago Thomas Caio 92 -
0
votes1
answer52
viewsError accessing Dictionary Code
I create a program to read from a file csv a set of coordinates and stores them in an object DataFrame. The code goes below df = pandas.read_csv(os.getcwd() + "/Coordinates.csv")…
-
0
votes2
answers1225
viewsHow to check if the txt file has a blank space on the last line
i have a script here that searches all the files . txt from a folder and then joins them in one file only. The problem is that some files have a " n" in the last row, causing the next line not to be…
-
0
votes1
answer452
viewsGrammatically classify a word in English
It is known that it is possible to classify the words morphologically through the nltk module, but it works directly with English only, being necessary for other languages a complicated process. Is…
-
0
votes3
answers1636
viewsStart numeric variable with null value in Python
Browsing the Python Brasil site, I decided to do exercise 1 of the Repetition Structure list: "Make a program that asks for a note, between zero and ten. Display a message if the value is invalid…
-
0
votes2
answers7124
viewsHow to get the directory from the location where a . py file is running?
I have a file. py of setup, so every time it runs I need to know the directory from where it is running, how can I do this?
-
0
votes1
answer147
viewsHow to disable text cursor?
I have a project in Gtk, which uses a Gtk.Entry text input and I need to disable the text cursor, or make it invisible. How can I do this? Or if I can’t, you can disable the linux system cursor?…
-
0
votes1
answer527
viewsTkinter function running even without clicking the button
Here is my code: from tkinter import * from tkinter import messagebox def add(a, b): messagebox.showinfo("Resultado", a.get()+b.get()) win=Tk() win.geometry('300x200') a=StringVar() b=StringVar()…
-
0
votes4
answers361
viewsComparison between random number and typed number never says it’s right, even though the numbers are equal
I’m trying to make a program in which I can type a number n and then I would like to generate a random number between 1 and 2. If that random number is the same as n, would show "You won!" and…
-
0
votes1
answer119
viewsProblem with Pytest
I am trying to apply pytest in a project that uses Bhaskara’s Formula, because it is giving error and I am not able to solve. The following will be the codes with the error. Thank you. import math…
python-3.xasked 6 years, 11 months ago Fernando 227 -
0
votes1
answer103
viewsEquivalent to the "console.dir()" function in Python
There is, in the Python language (v3.6), some function that serves to display attributes and methods of an object, such as the console.dir() in Javascript? I would like to get an output similar to…
-
0
votes1
answer314
viewsRenaming file: 'str' Object has no attribute 'group'
I’m having a problem that may be quite trivial but I’m not getting it. I found in a text by regular expression a numerical sequence of type XXXX/YYYY, after that I need to rename the file . txt with…
-
0
votes1
answer684
viewsSyntax of the Lambda function
I’m right at the beginning of the Lambda function study and I’m pretty much lost. I know the code could be done only with the "sum" function but I want to learn the Lambda syntax. a = [] for b in…
-
0
votes2
answers135
viewsAdding points in a known data range
I am working on data analysis using Python and for this I am training SVC and K-Means algorithms. The data used for the training have a fixed spacing between each sample, because they are sampled by…
-
0
votes1
answer58
viewsIs it worth doing exercises that teach not very optimized ways of doing a program?
Well, I’m learning python and sometimes I come across some relatively difficult exercises, for example, an exercise where the program had to read a value in money and say in how many notes of 1, 5,…
-
0
votes1
answer451
viewsHow to sort and sequence data from a file
I developed a program that stores a list of ids, so But for the desired purpose, the data should take the sequential form, so that the first pair of ids is something like: "889926212541448192"…
-
0
votes1
answer615
viewsHow to recover the return of a function that was executed within a Thread in Python3?
I need to run a function through a Thread only I’m not sure how to recover the return of this function. Below an example of how I want to do: from threading import Thread import time def…
-
0
votes1
answer567
viewsA question about python Pyautogui?
Is it possible for me to use Pyautogui in a browser that is not showing up on the screen ? Type I create a code for Pyautogui to work with the coordinates of a specific browser(eg Firefox) while I…
-
0
votes1
answer867
viewsHow to convert a saved string into a . txt file, to an integer number?
Example: test = open('test.txt', 'w') test.write('6000') close-up test.() How do I convert the contents of the . txt file into integer so I can do operations with it? in case you have no way to do…
-
0
votes1
answer1019
viewsPass a GET parameter through the Django view
i am trying to pass a parameter via GET in the URL through the Django backend, but I’m not getting it. My url to the page I want to pass the parameter to is…
-
0
votes1
answer111
viewsFind set of numbers in a list that together add up to X
I need to do a program where I have a list of numbers (1571.48 | 327.53 | 286.60 | 349.50 | 517.67 | 247.00 | 882.73 | 274.00 | 237.50 | 301.00 | 973.50 | 288.75 | 347.50 | 326.81) And I need to…
-
0
votes1
answer455
viewsError: unhashable type: dict_keys, how to resolve?
I have a code that accesses a CSV file through a function. I created a second function to change the header name of the columns (change name) and not to have to call it several times by changing the…
-
0
votes1
answer535
viewscan only concatenate list (not "str") to list
Hello, I’m new in python and programming I’m probably having a problem that should be very conceptual.I made this code to read a numerical sequence in a txt and rename it with the sequence found.…
-
0
votes2
answers2574
viewsIs there a command to finish the program in Python?
For example, I’m writing a code def soma(): n1=int(input('digite um numero')) n2=int(input('digite outro')) soma = n1+n2 print('A soma de {} e {} é {}'.format(n1,n2,soma)) #começo do programa…
-
0
votes1
answer663
viewsLogin information validation does not work
Doubts are throughout the program import string alphabet = list(string.ascii_lowercase) n = range(0, 10) name = input('Digite seu nome de usuário:') if name in n: while True: print('Apenas letras…
-
0
votes1
answer26
viewsDelete the last number I typed
Friends, one more question ( ). Observe the following Code: Numero = int(input('Digite um Numero')) inteiro = [] inteiro.append(Numero) while Numero>0: Numero = int(input('Digite um Numero'))…
-
0
votes1
answer1324
viewsString with larger and smaller number of characters
I wish to return to the greater and the lesser string. Look at: nl=str(input('Digite uma string')) String=[] string.append(nl) while caractere != 'pare': caractere = str(input("Digite uma letra ou…
-
0
votes1
answer1187
viewsProblems loading Static files to Django in deploy on Heroku
I’m trying to deploy an app I started in Jango on Heroku, but I’m having trouble loading the css/js/imgs files, follow below as my folders and settings related to it! py Settings. BASE_DIR =…
-
0
votes1
answer1150
viewsHow to configure Portuguese in kivy?
My App has two files, *.py and *.Kv, but I’m having problems with accents in my GUI. I’ve tried to resolve in the . py with file #encoding: -*- utf-8 -*- But the problem remains, please help me.…
-
0
votes1
answer229
viewsPython: how to edit tag with bs4
I have an html code, well polluted with Style in almost all tags, plus tags <font><span> unnecessary. How can I use beautifulsoup, to remove only attrs=style in <p> and the tags…
-
0
votes0
answers572
viewsHow to read a csv file with accentuated characters and transfer this data to a dictionary?
I have a csv file separated by ";" with two columns exported via excel: 1) Name of the person 2) e-mail of the person. However, the name contains accent and when trying to read the file and create…
-
0
votes1
answer92
viewsIs there any way to create different tables in SQLITE3 through the same python function?
I’m creating a python bot through the python-Telegram-bot library, and it works through commands. I know that through 'cursor.execute()' I can create a table via python, but the real question is: is…
-
0
votes1
answer33
viewsGet variable declared in function outside of developer
I tried with the module inspect but I couldn’t get the result. The concept is: "scan" a file through a decorator. Stages Capture variable file before function read_file be called "Scan" filing…
-
0
votes1
answer3941
viewsPython - Transforming line ranges into columns
I have a Dataframe with a column and 5,000 rows. What I need to do is take 48-line intervals and transpose to 48 columns with the entire dataframe How are you: 1. 0.35 2. 0.21 3. 0.45 4. ... 5. 0.12…
python-3.xasked 6 years, 7 months ago Celso Lopes 21 -
0
votes2
answers98
viewsPython problem using . Join
I need to print a MAC address, with tab ' : ', but I can only print the address with the tab at each string box, and the MAC address separates every 2 houses.
python-3.xasked 6 years, 7 months ago P.C 3