Posts by rick • 61 points
5 posts
-
-2
votes1
answer24
viewsQ: Perform the next step without going through a previous one
I have the following problem, if the user does not type either’S' or 'N' will return the error message I treated, however it will continue the loop, but I wanted a way not to ask again to type the…
-
2
votes1
answer83
viewsQ: formatting values of a dictionary
tamanho = int(input()) agenda = {} cont = 0 for c in range(tamanho): cont += 1 nome = str(input()).strip().lower().capitalize() cidade = str(input()).lower().capitalize() estado =…
-
0
votes2
answers52
viewsQ: I have the following problem on my tuple
def convertFarenheit(n): return (n * (9/5)) + 32 def convertCelsius(n): return (n - 32) * (5/9) def graus(temp1,escala1,temp2,escala2): dados = () if escala1 == 'C' and escala2 == 'C': soma = temp1…
-
-1
votes1
answer60
viewsQ: create a program that reverses the numbers using while, but my program will always ignore 0 at the end, how can I fix it?
def inverte(n): sequência = '' while n > 0: digito_invertido = n % 10 n //= 10 sequência += str(digito_invertido) return sequência def main(): n = int(input()) print(inverte(n)) if __name__ ==…
-
1
votes2
answers117
viewsQ: Write a program that reads a character and displays the boolean value True (true) if it is a digit between ' 0' and ' 9' if not False (false)
def cont(caracter): digito = ord(caracter) return digito == 0 or digito == 9 def main(): usuario = str(input()) print(cont(usuario)) if __name__ == '__main__': main() Where is the error in that…