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, 2019 in Python by Gayatri
404 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, 2019 in Python by SDeb
• 13,300 points
493 views
0 votes
0 answers

How is type conversion done in python?

How do you convert a list to ...READ MORE

Sep 3, 2019 in Python by Waseem
• 4,540 points
639 views
0 votes
1 answer
0 votes
0 answers

TypeError: 'type' object is not subscriptable when indexing in to a dictionary

I use dict to shorten things as ...READ MORE

May 24, 2022 in Python by Kichu
• 19,040 points
1,382 views
0 votes
0 answers

Python - TypeError: Object of type 'int64' is not JSON serializable

My data frame has store names and ...READ MORE

May 26, 2022 in Python by Kichu
• 19,040 points
2,540 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
1,970 views
0 votes
2 answers
+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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,441 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,077 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP