Adam Winwood
Adam Winwood

Reputation: 3

(Python) Removing quotation marks from called string in input

text = "Please enter your weight in", Measurement_system
weight = input(text)

I want to give the user a prompt for their input without it being enclosed in quotation marks

In response to the above code it displays:

('Please enter your weight in', 'imperial')

Does anyone know how to get rid of these quotation marks? Thanks :)

Upvotes: 0

Views: 218

Answers (1)

Kevin
Kevin

Reputation: 76194

Your text value is actually a tuple because you used a comma during assignment of text. Instead, concatenate the strings.

text = "Please enter your weight in " + Measurement_system
weight = input(text)

Or you could use string formatting (although it's a little overkill in this situation IMO):

text = "Please enter your weight in {}".format(Measurement_system)
weight = input(text)

Or, the older string formatting syntax

text = "Please enter your weight in %s" % Measurement_system
weight = input(text)

Upvotes: 5

Related Questions