How can i make this code loop in Python -
this code supposed turn decimals binary, figured out part need code go previous question of asking type in integer instead of closing program when calculations done.
here have far
def binary(n): if n > 1: binary(n//2) print(n % 2,end = '') dec = int(input("enter integer: ")) binary(dec) input("\n\npress enter key exit.")
both for loop , while loop achieve required outcome, depending on how many times want statement loop. if know amount of times, use loop, if comparing condition, while loop best. find syntax for loops in python here
Comments
Post a Comment