Explicit type conversion not happening

0 votes

I have the following python code:

playerlocation =(input("Player location?"))
playerlocation = list(playerlocation.split(","))

for x in playerlocation:
try:     
     x = int(x)
     coordsareintegers = True
     print(playerlocation)
except:
     coordsareintegers = False

When I print X, it should logically be printed as int but instead they are printed as string. Am I going wrong somewhere?

May 28 in Python by Gayatri
7 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Python

0 votes
1 answer

python structured/recarray type conversion behaviour

You need to specify a string width, ...READ MORE

answered May 15 in Python by SDeb
• 10,860 points
7 views
+1 vote
5 answers

Check whether the file exists or not?

Use this import os os.path.exists(path) # Returns whether the ...READ MORE

answered Oct 18, 2018 in Python by reyam
65 views
0 votes
1 answer

Raw_input method is not working in python3. How to use it?

raw_input is not supported anymore in python3. ...READ MORE

answered May 4, 2018 in Python by aayushi
• 750 points
93 views
0 votes
1 answer

Type checking in Python

Use the type() function with the variable ...READ MORE

answered May 8, 2018 in Python by Nietzsche's daemon
• 4,260 points
12 views
0 votes
1 answer

What are the differences between type() and isinstance()?

To summarize the contents of other (already ...READ MORE

answered Jun 4, 2018 in Python by ariaholic
• 7,320 points
22 views
0 votes
1 answer

Python 'If not' syntax

Yes, if bar is not None is ...READ MORE

answered Aug 1, 2018 in Python by Priyaj
• 56,140 points
33 views
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
56 views
+4 votes
6 answers

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.