Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 BBCode tags
#1
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
Quote
#2
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.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures

Quote
#3
(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: ")) ?
Quote
#4
(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.
Quote
#5
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.
Quote
#6
and errors between icon circle with X in middle.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  People Not Using Code Tags micseydel 16 2,041 Dec-09-2017, 06:49 AM
Last Post: micseydel
  Just a trial. For learning code tags sylas 3 1,295 Sep-25-2017, 11:41 AM
Last Post: metulburr
  Help with BBCode pyJim 2 1,088 Aug-22-2017, 10:05 PM
Last Post: snippsat
  Weird Python tags syntax coloring bug micseydel 4 1,781 Jun-02-2017, 05:04 AM
Last Post: nilamo
  note moderator instead of mod tags metulburr 7 1,850 Apr-11-2017, 01:05 PM
Last Post: metulburr
  Please use code tags Larz60+ 28 5,659 Apr-06-2017, 09:47 PM
Last Post: metulburr
  Do not know how to add "Code Tags" or "Error Tags" to my submissions mattkrebs 2 1,197 Mar-21-2017, 04:15 PM
Last Post: metulburr
  BBcode pointer position metulburr 0 1,068 Dec-15-2016, 01:35 PM
Last Post: metulburr
  Created a plugin for our code tags stranac 18 4,965 Dec-13-2016, 12:16 PM
Last Post: Kebap
  bbcode fail [list=0] Skaperen 2 1,373 Nov-12-2016, 01:49 PM
Last Post: metulburr

Forum Jump:


Users browsing this thread: 1 Guest(s)