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
11 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
• 13,160 points
13 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
79 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
113 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
14 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,340 points
33 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,520 points
41 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 175 views
+4 votes
6 answers