Creating numbered list of output

You’d still use enumerate(); you didn’t show how you used it but it but it solves your issue: for index, (value,num) in enumerate(sorted_list, start=1): print(“{}.\t{:<5}\t{:>5}”.format(index, value,num)) I folded your str.ljust() and str.rjust() calls into the str.format() template; this has the added advantage that it’ll work for any value you can format, not just strings. Demo: … Read more

python calculator with two float numbers as parameters [closed]

Hope this code may help you def add(a,b): print(a+b) def subract(a,b): print(a-b) def multipy(a,b): print(a*b) def divide(a,b): print(a/b) ch=”y” while ch==”y” or ch==”Y”: x = float(input(“first number : “)) y = float(input(“second number: “)) print(“…..MENU…….\n 1.Add\n 2.Subtract\n 3.Multiply\n 4.Divide\n”) op=int(input(“Enter your choice : “)) if op==1: add(x,y) elif op==2: subract(x,y) elif op==3: multipy(x,y) elif op==4: … Read more

How to remove curly bracket from the output in python?

You are inserting a list or tuple into the listbox instead of a string. You need to explicitly convert each row to a string before passing to the insert method. Otherwise, the underlying tcl interpreter will try to preserve the list-like structure of the data by adding curly braces or backslashes when converting the value … Read more