Most voted "python" questions
Python is a dynamic and heavily typed programming language whose design philosophy emphasizes usability. Two similar but incompatible versions of Python are in use (2 and 3). Please mention the version you are using when asking a question about Python.
Learn more…8,642 questions
Sort by count of
-
-1
votes2
answers62
viewsfor function in Python3 - how to print all elements of a series
i = 0 for item in test['text'][i]: print(test['text'][i]) print(i) i+=1 in my dataset "test" I have 3262 items( is a series ) however when I do "for" it "printa" only 32 items…
-
-1
votes1
answer55
viewsI need help with this code
Personal I wrote the following simple code in my python: nome = str(input("Qual o seu nome?")) if nome == 'denise': print("Nome bonito") elif nome == 'maria' or nome == 'pedro' or nome =='joao':…
-
-1
votes1
answer260
viewsTransfer the value of a variable to Ctrl+C in Python?
I’m doing a job and need the value of a variable to go to the Clipboard so I can use it at another time. You can do this in Python v2.7?
-
-1
votes2
answers85
viewssklearn library accuracy_score error
from sklearn.svm import LinearSVC from sklearn.metrics import accuracy_score # retorna 1 se houver mais de 1 número 1 treino_x = [[1,0,1],[1,1,0],[0,0,1],[0,1,1]] teste_x…
-
-1
votes1
answer832
viewsDate query in python calendar?
I’ve been studying python for just over a week, but I’d like to perform a more action or bros as follows. will be placed the monetary value and places the day of closing the card and the day of…
-
-1
votes1
answer158
viewsHow can I view an Axessubplot object in the same way as pyplot.show()?
I’m learning how to deal with pandas and after getting a Dataframe, the next step was to get a chart of this Dataframe "Upermarket": supermarket.loc[:10, 'Total'].plot(figsize=(14, 6)) This results…
-
-1
votes4
answers1516
viewshow it returns the indices of a python list
I have the list: lista = [0,0,0,0] How can I return the contents of this list so it stays that way: Índice: 0 1 2 3 item: 0 0 0 0 def f1(): #funcão criar um post, cria um novo post com 0 likes…
-
-1
votes2
answers66
viewsReceive items from an ordered list in a variable - Python
Good afternoon, you guys! I started studying Python recently, and I have a question that may seem basic but it’s complicating me. I wanted to receive the items of a list in an ordered form variable.…
-
-1
votes2
answers725
viewsInserting images into a Tkinter frame
I’m trying to add an image inside a Frame using the Tkinter through the code below: class Gui(): """ Implements a GUI for Interactive Dictionary app """ def __init__(self, parent): self.parent =…
-
-1
votes1
answer41
viewsBeautifulsoup - href search by text
Good afternoon everyone, I’m with a problem that I haven’t been able to solve or found any related. If I have: codigo_pagina = '''<li><span><span style="font-family: Courier…
-
-1
votes1
answer83
viewsWhere is the Output error?
I am using the Pandas library (from Python). I opened my CSV file with head function(), However, the output obtained has the data/values all together. Where is the bug/ How can I fix?…
-
-1
votes1
answer156
viewsHow to find a value between two tags in an HTML text? Other than "XPATH"
I’m trying to extract the value between two HTML tags with Python, I need it between two tags same. I was doing it this way to extract values from a store catalog. But now I have a need to extract…
-
-1
votes1
answer62
viewsExit "while" by filling lists
I need to make a code that uses while and lists, which aims the user to register an undetermined number of people while he wants and put 0 to finish and show on the screen the created list. It is…
-
-1
votes1
answer147
viewsInstallation of libraries in python
I’m trying to install the library chatterbot and the library pocketsphinx, but at installation time the prompt shows the following error: ERROR: Command errored out with exit status 1: command:…
-
-1
votes1
answer24
viewsVGG16: how to use Dense_2 layer as output - python
I am using vgg16 model for feature extraction https://github.com/fchollet/deep-learning-models/blob/master/vgg16.py call the same through function: model = VGG16(include_top=True,…
python classification image-processing model deep-learningasked 4 years, 7 months ago David Jordão 21 -
-1
votes2
answers85
viewsText manipulation error with Python
I wrote this script to check if the texts are the same, if you do not add the texts you do not have in the other file, but I am receiving this error syntax and I do not understand the reason, is it…
pythonasked 5 years, 7 months ago Julio Vilela 1 -
-1
votes1
answer115
viewsSplit subdictionaries in python
Good guys, I created a ICT, and I divided it using the function: listOfDicts = [{k:v for k,v in dictionary.items() if k%10==i} for i in range(10)] From that, I got 10 sublists: listOfDicts[0 a 9]…
-
-1
votes1
answer919
viewsPython recursive function that returns the largest and smallest value within a list
Could someone help me with a light? I can do the recursive function to find the lowest value in a list, and the highest value separately. But a function returning the two together I cannot. The…
-
-1
votes1
answer137
viewsError of migration, Flask
is appearing, "Nameerror: name 'app' is not defined" my codic from flask import Flask from flask_sqlalchemy import SQLAlchemy from flask_script import Manager from flask_migrate import Migrate,…
-
-1
votes1
answer189
viewsUpdate Python 3x
I have version 3.7.3 of Python (for studies only) in my Raspbian Buster and would like to update it to the latest version (3.8.3). I’ve tried to use sudo apt update and sudo apt upgrade but the…
-
-1
votes1
answer39
viewsHow do I consider just what number a user enters in an input? (python)
rabanada = int(input("Quantos quilos você pesa? ")) if rabanada > 100000: print("Você é gordo") else: print("Você tá magro, rlx") If the user type: "100 kilos", as I do for the program consider…
-
-1
votes1
answer280
viewsSyntax error in mathematical equation (pyflakes E)
The code below, written in python, has syntax error in the equation Ff. I searched for problems related to closing the parentheses, rewrote the equation and still get the error message. While…
-
-1
votes1
answer216
viewsSort() - Python
Good evening guys, I’m starting in python and I’m having a doubt that I can not think of a solution... I made a code to generate 6 numbers in a list and print without repeating any items but…
-
-1
votes1
answer280
viewsReturn data from two identical tables [SQL] [Python]
Hi, I want a help with SQL query. There are two identical tables but with different recorded data in each one. How can I get the data from both tables? As if they were two selects in each table?…
-
-1
votes1
answer165
viewsX-axis positioning using Matplotlib in python 3.x
I made the code below to print a graphic however precise that the x-axis is at the point(0,0). I tried several paths and could not help? I believe it’s something simple but I couldn’t find. import…
-
-1
votes1
answer95
viewsError after updating PIP version - Python
i went to update the version of Pip on my machine and now when I go to install a library the following error appears: WARNING: pip is being invoked by an old script wrapper. This will fail in a…
-
-1
votes1
answer42
viewsHow to assign the result of a while/for to a list so it can operate with the values
n = int(input("what range?")) f1=0 f2=1 cont = 1 while cont <= n: f3 = f1 + f2 f1 = f2 f2 = f3 if f3 % 2 == 0: print(f3) # Como eu somo os valores de f3 ou transformo ele em uma lista? cont += 1…
-
-1
votes1
answer303
viewsProblem updating Pip on CMD
I am trying to use Robot Framework and one of the steps is to make this IP work in cmd....…
-
-1
votes2
answers112
viewsHow to create a file within a directory?
import os def main(): checkDir = str(input('Escoha o diretório do arquivo Python: ')) if os.path.exists(checkDir): print('O diretório existe!') print() nameDir = str(input('Digite o nome do novo…
-
-1
votes1
answer94
viewsPython with float variable problems
Galera wrote a program where I decrease a variable in 0.01 and from the third decrease, python simply recognizes the value 0.01 as 0.009999999999988617 and ends up giving problems in my code. In the…
-
-1
votes1
answer40
viewsOutput layer neural nets?
Guys, in building a neural network for image classification in my output layer the amount of neurons should match the amount of classes in my data set?
-
-1
votes1
answer32
viewsError 'Attributeerror' in python
I have that error in python with requests, web scraping!: from bs4 import BeautifulSoup as bs from requests import * base_url = 'https://www.vagas.com.br/' jobsurl = f'{base_url}/vagas-em-recife'…
pythonasked 4 years, 6 months ago Rhuan Galvão 9 -
-1
votes1
answer18
viewsHow do I keep the word iris-setosa as text in python: df=pd.read_sql('SELECT class = 'iris-setosa' FROM tbl_iris',cnxn)
Olha o conexão já foi feita com sucesso no SQL Sever, já testei comandos como: df=pd.read_sql('SELECT class FROM tbl_iris',cnxn) ou até mesmo df = pd.read_sql('SELECT…
-
-1
votes1
answer44
viewsHow to make a python program capable of executing the ifconfig command and displaying its output on the screen?
Good morning!!! I need to make a python script capable of executing the ipconfig command and displaying its output on the screen. Anyone knows how I can do it?
pythonasked 4 years, 5 months ago Nicolas Hack 1 -
-1
votes2
answers502
viewsAssociating positions with Python elements
Make a program that reads two lists with 10 elements each and calculate another list containing at even positions the values of the first and at odd positions the values of the second. Please help…
-
-1
votes1
answer66
viewsSplit returning Indexerror
I have a file that the lines have this pattern: 0.22755189537 SN.node[0].Application SENDING BEACON # 0 0.22755189537 SN.node[0].Application Sending [Beacon] of size 105 bytes to communication layer…
-
-1
votes1
answer888
viewschatterbot_corpus module not found after installing chatterbot
Does anyone know what these mistakes can be? C:\Python37_64\venv\Scripts\python.exe C:/Python37_64/chat.py Traceback (most recent call last): File "C:/Python37_64/chat.py", line 1, in <module>…
-
-1
votes1
answer179
viewsSending a C++ vector to a Python function
I have the following function written in python in a file. py: def coordinate(arg): print arg return True And an example of C++ code in a file. CPP #include <Python.h> #include <vector>…
-
-1
votes1
answer41
viewsExcept bugging without being called
well, I made a "minigame" with even a save/load system. the problem is that after saving or loading the game, ask to "mine", the script returns me the except command of the first command. guy: i…
-
-1
votes1
answer665
viewsNameerror: name 'mostrar_urls' is not defined
Good afternoon! I’m trying to develop a project/idea I had, only when I went to put the "menubar" in other "parts of the programme" the program does not "whether" run further, can anyone help me…
-
-1
votes1
answer126
viewsEmail outlook using Flask
I’m trying to create a code that sends email outlook with flask, but for some reason it won’t, I tested with gmail, tbm is not going from flask import Flask from flask_mail import Mail, Message app…
-
-1
votes2
answers390
viewsReceive an integer number in the input, calculate and print the sum of the odd digits of this number in the output
I saw a similar doubt and he used this code, but in my case I need him to add up only the odd numbers he gets. For example, when typing 123, instead of adding up 1+2+3 it should add up 1+3 only. How…
-
-1
votes1
answer381
viewsHow to convert Object to number in pandas?
import pandas as pd arq = pd.read_csv("arquivo.csv", sep=";") I want to use values in the Valor but is in object. But when I use the code arq["Valor"] = arq["Valor"].astype(int) error appears:…
-
-1
votes1
answer19
viewsReturn specific column with csv library
I have a sheet with 4 columns and 2 rows and I want to return the column age, without the column identifier, only the contents of the rows. Code: import csv def get_column_of_csv(filename, column):…
-
-1
votes1
answer977
viewsScatterplot trend line in Python matplotlib
Suppose I have two simple Python lists and create a scatter chart: x = [548, 677, 987, 2, 29, 1114, 521, 999] y = [96, 775, 258, 369, 410, 99, 5, 1117] import matplotlib.pyplot as plt plt.scatter(x,…
-
-1
votes1
answer1372
viewsHow to write to a txt file in Python?
How to open a txt file and add the contents of some variable in it? For example, a content that leaves the print in the code below. for passw in senha_list: print(passw,end='')…
-
-1
votes1
answer59
viewsCall another screen in Kinter
I’m trying to create a main screen with two buttons to call the screens "Stock and "Customers", but instead of closing and opening, it adds on the same screen. from clientes import Clientes from…
-
-1
votes1
answer120
viewsHow can I add up times told by the user?
from datetime import datetime inicio = input( 'Informe o horario de inicio do experimento (formato Horas:Minutos:Segundos): ') termino = input( 'Quanto tempo durara o experimento (formato…
-
-1
votes3
answers144
viewsCheck magic numbers (those whose square root is a prime number) within a range
I wonder why it doesn’t work. import math #Se a divisão do numero der um primo, o número é mágico is_magic = [] for n in range(8, 27): cont = 0 if pow(n,(1/2)) == 2 or 3 or 5 or 7: cont += 1…
pythonasked 4 years, 3 months ago Nayara Souza 29 -
-1
votes1
answer46
viewsSimilar command to python’s Try for shellscript?
I need to formulate a . sh to run a code if the first error: !#/bin/bash python main.py python3 main.py As if it were a python (Try/Except) exception. I thought about creating two . sh scripts, to…