Python Forum
BBCode tags - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Forum & Off Topic (https://python-forum.io/forum-23.html)
+--- Forum: Board (https://python-forum.io/forum-26.html)
+--- Thread: BBCode tags (/thread-15190.html)



BBCode tags - NLittle17 - Jan-07-2019

So I am trying to create a function for odd integers. I would like to have the user input any number and then have the program test if it is evenly divisible by 2. If so, I would like it to return False and if it is not true I would like to return True. Here is what I have so far:

print("PRACTICE 2.")

number = input("Enter a number, please: ")

def is_odd(number):
if number % 2 == 0:
return False
else:
return True
is_odd(number)

Output:
Enter a number, please: 5 (entered by me to test)
Traceback (most recent call last):
File "python", line 13, in <module>
File "python", line 9, in is_odd
TypeError: not all arguments converted during string formatting



RE: Functions in Python - ichabod801 - Jan-07-2019

Use python tags. You have been asked to do this repeatedly.

You need to convert number to an integer with int() before applying the % operator.


RE: Functions in Python - NLittle17 - Jan-07-2019

(Jan-07-2019, 05:50 PM)ichabod801 Wrote: Use python tags. You have been asked to do this repeatedly. You need to convert number to an integer with int() before applying the % operator.

I never see the option to add any tags so apologies, repeatedly. So like:

number = (int(input("Enter a number, please: ")) ?


RE: Functions in Python - metulburr - Jan-07-2019

(Jan-07-2019, 05:55 PM)NLittle17 Wrote: I never see the option to add any tags so apologies
read the help docs about BBCode
https://python-forum.io/misc.php?action=help&hid=25

You need to learn to use code tags otherwise you will be restricted from posting.

In addition to that, please be more specific in title descriptions. Your two questions were not the same, but had the same title. I almost merged them together until i realized they were different questions. I fixed your two thread titles to identify the main question of each thread.

EDIT: I just realized you made a 3rd thread, however used proper BBCode. In that case, ill just move this to Board for BBcode instructions as the other thread is a duplicate.


RE: Functions in Python - marienbad - Jan-07-2019

Nlittle17 - when you make a post, do you see those little icons above the text box, mainly the blue and yellow python icon? Click that, stick code between the python tags.


RE: BBCode tags - Larz60+ - Jan-07-2019

and errors between icon circle with X in middle.