0

I want to add things to a string without any commas.

I have a string URL: http://gdata.youtube.com/feeds/api/standardfeeds/feed_str?max-results=max_result&time=

feed_str = top_rated
max_result = 5
time_str = today
web_str = "http://gdata.youtube.com/feeds/api/standardfeeds/",feed_str, "?max-results=" ,max_result,"&time=" + time_str

it prints like this

('http://gdata.youtube.com/feeds/api/standardfeeds/', 'top_rated', '?max-results=', '5', '&time=today')

and I want it to print like this:

('http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?max-results=5'&time=today')

which is just one string. Any help?!

  • 1
    The clue is already in your code. Look at your output. What's different about the way you use the variable `time_str` in your string construction? – ire_and_curses Nov 29 '11 at 17:57

3 Answers3

3

Here's a hint ; you are looking for a way to concatenate strings.

Timothy Groote
  • 8,614
  • 26
  • 52
2

String concatenation is what you are looking for and SO has many threads on this topic ( String concatenation vs. string substitution in Python , Concatenation Operator + or , ,...)

Community
  • 1
  • 1
gecco
  • 17,969
  • 11
  • 51
  • 68
0

Simply remove the commas on the web_str and put the signal '+' in their places.

jonathan.hepp
  • 1,603
  • 3
  • 15
  • 21
  • 1
    Yes, very good. However, most people think it's better to offer hints for [tag:homework] questions, rather than answering them directly, since this gives the questioner a chance to learn, rather than just complete assignments. See [How to ask and answer homework questions](http://meta.stackexchange.com/questions/10811/how-to-ask-and-answer-homework-questions) for more. – ire_and_curses Nov 29 '11 at 18:10
  • I'm sorry, my bad. Didn't see that was a homework question. I'll pay more attention next time. Thank you for advise. – jonathan.hepp Nov 29 '11 at 18:15