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
  • 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? Commented Nov 29, 2011 at 17:57

3 Answers 3

3

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

Sign up to request clarification or add additional context in comments.

Comments

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 , ,...)

Comments

0

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

2 Comments

Yes, very good. However, most people think it's better to offer hints for 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 for more.
I'm sorry, my bad. Didn't see that was a homework question. I'll pay more attention next time. Thank you for advise.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.