start = int(input("Enter a number: "))
for number in range (1, start + 1):
if (number % 2 != 0):
print("{0}".format(number, ','))
I have this code that works, but when it outputs, it does so in different lines. How to I get it to display as 1,3,5,...?
def find_odd_even_till_a_num(last_num):
even_list = []
odd_list = []
num = 1
while num <= last_num:
if (num % 2) > 0:
even_list.append(num)
else:
odd_list.append(num)
num = num +1
print(str(odd_list), "is ODD number")
print(str(even_list), "is Even Number")
find_odd_even_till_a_num(100)
You can try this . May be it gives the desired output..
Try this, print function in python has a paramenter value "end" and its default value is always set to "\n" so we need to change that.