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,081
  • 18
  • 17
  • 16
mr_swap
  • 339
  • 1
  • 2
  • 10

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,824
  • 17
  • 99
  • 186
Hiren Jungi
  • 854
  • 8
  • 20