Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,770 members, 7,955,942 topics. Date: Sunday, 22 September 2024 at 07:14 PM |
Nairaland Forum / Science/Technology / Programming / Python Experts (1224 Views)
Python �� Beginners And Experts / [Code Review Help] Laravel Experts Please HELP! / Unity 3d /unreal Engine Experts? (2) (3) (4)
Python Experts by Trizyd(m): 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:" 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:" 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(m): 3:43pm On Aug 09, 2019 |
pavicky: Yeah, thanks I just found out too.. |
Re: Python Experts by Trizyd(m): 3:45pm On Aug 09, 2019 |
pavicky: 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 2 Likes |
Re: Python Experts by Daejoyoung: 3:46pm On Aug 09, 2019 |
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)
Please Someone Help Me Fix My Facebook Account / Data Mining With Python / Data Structures And Algorithms
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 11 |