-7

I want to convert my input from int to string but i cannot do it! This is my code! Please help!

 def hi(x):

       print x

if I put a letter for x,an error message comes! I don't want to give my input within double quotation marks.without doing that, is there any way?

Tharushi Geethma
  • 1,249
  • 15
  • 21

2 Answers2

1

Its quiet simple.

def hi(intx):
   target = ''.format(intx)
   print target 
Bhanu Kaushik
  • 876
  • 6
  • 25
  • 2
    Yea but that does not mean that your question was clear. This is indeed a duplicate questions and the moderators are right about that. – Bhanu Kaushik May 19 '15 at 15:19
1
def hi(x):
    print(type(x))
    x= str(x)
    print(type(x))

So your argument is an integer but when you do str(x), you change the data type to string.

Alina DW
  • 111
  • 1
  • 17