Posts by Renan Machado • 56 points
3 posts
-
3
votes1
answer74
viewsA: Format an object print
To change what will appear when you pass the object to the print() method, you must override the method __str__() of the object and return a string. class Tupla: def __init__(self, keys, palavras):…
-
0
votes1
answer94
viewsA: Input of various inputs
As I can not comment, I will try to answer, but I do not know exactly what you are trying to solve. To give break, your code needs to be within a loop, so your code already works normally. while…
-
1
votes2
answers82
viewsA: Python - is it possible to use lambda in print with format (f or .format)?
What you need in this case is not lambda, but use ternary operator. Follow an example: num = 1200 mil = int(num/1000) print("o numero tem {} {}".format(mil, "milhar" if mil == 1 else "milhares"))…