Questions tagged as 'python-3.x'

1
answer

Identify repeated elements in list with Python

The list I made should read the repeated values from a list and show their positions, but it did not work correctly lista = [] listaRepetido = True for i in range(4): lista.append(int(input("Numero: "))) for i in lista: for j in rang...
asked by 28.06.2017 / 22:44
2
answers

Python 3 make the program discover how much of a given digit has a string or a number

It's for python 3: I'm trying to do a pretty basic program to figure out how much of a given digit it has in a string or a number. For example, if the user types 1200, I want to print- "your number has 2 zeros" .... or if the user types "h...
asked by 25.08.2017 / 07:55
1
answer

Associate two lists in python

Associate two lists, a list with car name and another list of colors and each one containing n elements: listaCarros = ["gol","uno","corsa","palio","idea"] listaCores = ["branco","verde","preto","cinza","azul"] with the output in this forma...
asked by 23.09.2017 / 17:58
1
answer

Recursive function that returns the sum of the digits of a number

I need to create a recursive function that receives a number n integer and returns the sum of the digits of this number. I made the following code but it is giving None : def somadig(n, s = 0): if n > 10: d = n%10...
asked by 10.12.2018 / 15:42
2
answers

Conditional structure does not work

Several times, especially when the second price is higher than the others, the program charges that it is the cheapest. #Faça um programa que pergunte o preço de três produtos e informe qual produto #você deve comprar, sabendo que a decisão é...
asked by 31.12.2018 / 20:05
2
answers

Replace string with regex in python 3

I have a code that overrides certain string by whitespace dados = '[{"Id":12345,"Date":"2018-11-03T00:00:00","Quality":"Goodão","Name":"X","Description":null,"Url":"x.com.br/qweqwe","ParseUrl":"x-art","Status":"Ativa","Surveys":0,"KeySearc...
asked by 05.11.2018 / 00:40
1
answer

Specify DNS server when resolving address

I would like to do something like an "nslookup" to resolve an address of a site through my DNS servers, because in the example below, I only get through DNS that I have in my machine. How could I tell the IP of my server to resolve the Google...
asked by 11.03.2017 / 20:05
2
answers

Print the largest substring of s where letters occur in alphabetical order

Let s be a string with all lowercase characters. Write a program that prints the largest substring of s in which letters occur in alphabetical order. For example: s = 'azcbobobegghakl' The program should print: beggh If there a...
asked by 16.04.2018 / 00:29
2
answers

Can you replace commands with variables in python?

I'm having a question, can I save commands in variables? For example: X = while X (True): So I could facilitate some things in some scripts, or kind of try to "create" a proper language, I hope someone can help me! : -)     
asked by 02.05.2018 / 04:50
2
answers

How to make powers of 9 quickly

I'm asking a question that asks to raise the number to 9 and say the last digit I got, but the resolution seems to have passed the time because it had a number of 10 ^ 9, how to solve it in a faster way My code import math while True: try:...
asked by 23.05.2018 / 19:48