0

I am trying to replace part of url by gene id using python 3.5. Can someone help me in replacing 'xxx' by integer stored in variable input_id?

input_id = 135
my_url = "https://www.ncbi.nlm.nih.gov/gene/xxx"
Bellerofont
  • 1,083
  • 18
  • 17
  • 16
mr_swap
  • 149
  • 1
  • 9
  • 2
    Possible duplicate of [Python String and Integer concatenation](http://stackoverflow.com/questions/2847386/python-string-and-integer-concatenation) – Pierre Jan 26 '17 at 07:22
  • Possible duplicate of [Making a string out of a string and an integer in Python](http://stackoverflow.com/questions/2823211/making-a-string-out-of-a-string-and-an-integer-in-python) – Tom Jan 26 '17 at 08:57

1 Answers1

0

Try this code.

my_url = "https://www.ncbi.nlm.nih.gov/gene/xxx"
input_id = 135
print my_url.replace("xxx",str(input_id))

o/p: https://www.ncbi.nlm.nih.gov/gene/135 
halfer
  • 19,471
  • 17
  • 87
  • 173
Hiren Jungi
  • 856
  • 8
  • 19