₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,324,996 members, 8,419,860 topics. Date: Thursday, 04 June 2026 at 03:52 AM

Toggle theme

Python Experts - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingPython Experts (1370 Views)

1 Reply (Go Down)

Python Experts by Trizyd(op): 1:31pm On Aug 09, 2019
I'm currently learning Python programming language, and currently working on Control Flows.. I have this issues, if I can't figure out a problem, I just get stuck there. I'm working on an exercise to give me the data type of an input.

Here's a code I did that worked

data = 11
type(data)
if type(data) == str:
print( "It's a string" )
elif type(data) == int:
print("It's an integer" )

print(type(typed))


The output is
Its a number


Now my problem, I want to use a raw input, it prompts the user to type in something, it then determines if it's a string or integer

I used raw_input=("Enter something : " )


But my output no matter what I input is always converted to string

And ideas for me?
Re: Python Experts by Nobody: 3:27pm On Aug 09, 2019
p= input(" please input data:"wink
if not p.isdigit(): print (" this is a integer data type" , p) else: print(" this is string data type", p)
NOTE: p is the variable name isdigit is a string method
Remember, you can iterate it in a loop like while True: p= input(" please input data:"wink
if not p.isdigit(): print (" this is a integer data type" , p) else: print(" this is string data type", p) enjoy...
Re: Python Experts by Nobody: 3:31pm On Aug 09, 2019
don't use raw_input() it is outdated for python 3x input() is used
Re: Python Experts by Trizyd(op): 3:43pm On Aug 09, 2019
pavicky:
don't use raw_input() it is outdated for python 3x input() is used
Yeah, thanks I just found out too..
Re: Python Experts by Trizyd(op): 3:45pm On Aug 09, 2019
pavicky:
p= input(" please input data:"wink

if not p.isdigit():
print (" this is a integer data type" , p)
else:
print(" this is string data type", p)

NOTE: p is the variable name
isdigit is a string method

Remember, you can iterate it in a loop like
while True:
p= input(" please input data:"wink

if not p.isdigit():
print (" this is a integer data type" , p)
else:
print(" this is string data type", p)
enjoy...
Thanks, it works... Except for the if not p.isdigoit should have a print statement of string type will the else that's the integer.. buh thanks.. Python is getting more interesting
Re: Python Experts by Daejoyoung: 3:46pm On Aug 09, 2019
smiley
Re: Python Experts by micodon(m): 5:43pm On Aug 09, 2019
Raw_input and input always returns a string
Re: Python Experts by romeo1000(m): 12:07pm On Sep 25, 2022
Hello . Do forgive my going offpoint but I have a question concerning mellin thread and Amira(the moon name)
Re: Python Experts by quickhubservice: 9:33pm On Sep 25, 2022
methods would help

1 Reply

Python Experts Needed In LagosForum Redesigned Job For Experts[Code Review Help] Laravel Experts Please HELP!234

Which IT Course Can I Study Without Disrupting My Banking Career.Who Would Teach Me ProgrammingI Need A Strong Team Members To Work On A Big Project