Lesson 30 ranges | Sololearn: Learn to code for FREE!

+2

Lesson 30 ranges

I have just learnt about ranges in lesson 30, and can do them correctly if using fixed data. I can get the sample input and output to work and give me the desired outcome, but the lesson didn’t cover how to code ranges using user input, and this is where I am stuck. I googled for an answer, but the methods I found didn’t work. Any guidance to help me would be greatly appreciated.

1/15/2022 4:01:57 AM

Gina

15 Answers

New Answer

+1

Thank you for responding to my question. I’m sorry, I am new on here, i started on Monday, so I am just learning how to do anything, whether programming or interacting with others. I didn’t realise that i needed to post code in query, and i deleted what i had done to start fresh, it was a mess, lol. I have no doubt i will end up where i started again, so i will post code then. Thank you for your guidance, i’ll be back when i have code again.

+10

No worries Gina , take your time for learning. If you make any code or projects use Sololearn playground. For open ended discussion you can always create posts in your activity feed. It is always helpful to share your code or attempt you have done so far. So, that we can help you from the step you got stuck. Check out the links belows: One is community forum and guidelines link: https://www.sololearn.com/Discuss/1316935/?ref=app Another is helpful for getting helpful answers based on how informative your code/question is: https://www.sololearn.com/Discuss/333866/?ref=app

+9

Please share your attempt so that community members can help.

+5

You're most welcome Gina ! :) A little help for you on how to mention someone in q&a discussions for those you help or others are helping you. Use "@" before whomsoever name. This way they will get informed your response, just in case if they are not following thread after helping. Happy learning! 🌷🌸 Edit: Have a great week ahead Gina & stay safe!

+4

In this challenge, you don't need to change two arguments(2005,2011) to an input variable. You just have to replace them as two input variables. x = int(input()) y = int(input()) l = list(range(x,y)) ...

+3

Gina I believe you mean something like r = int(input()) for i in range(r): or while r > 0: If this isn't what you meant please clarify ..

+3

Gina I believe the q&a and my short code will help you https://stackoverflow.com/questions/31227536/what-is-the-difference-between-range0-2-and-listrange0-2 https://code.sololearn.com/crOZQV1ME0hy/?ref=app

+3

Thank you everyone, your help and guidance has been invaluable. Simba, your solution, fixed my problem and showed me where i am lacking in understanding, i went down that path, but i couldnt work out how to combine the two, i kept getting Syntax error. I need to go back and study more on loops and ranges. Again, thank you everyone.

+3

BroFar thankyou for the resources, they are perfect for what I need.

+2

I known that X = list(range(2005, 2011) Print(x) I know that works when i run the test, but i need to convert “2005” and “2011” into input(), and that is what i am stuck on, converting the fixed data into user input. Everything i try comes back with a syntax error. I am giving it another crack at it soon (looking after my grand children at the moment) but meanwhile if you can point me in the right direction so i know what to study on, that would be appreciated.

+2

BroFar yes, which will probably save me endless confusion in the future. Me: “I write to people and they don’t write back” 😥 You guys: “Why doesn’t she ever reach out for help?” 🤔 So, by adding one extra keystroke saves all that drama 😂 Have an amazing week.

+1

Thank you Shivani, these links are very helpful, I will gain such a better understanding of how to go about things on here, making life so much easier. Everyone on here is so amazing, such a talent pool of knowledge, shared so generously, absolutely wonderful.

+1

Shivani 📚✍ You are so awesome, I had wondered about whether I had to use an addy “@“ or not, makes perfect sense, lol. Have an amazing week.

+1

Gina you are welcome and it looks like Shivani 📚✍ has taught you how to use the @ mention 👍

0

Ain't useful?: https://stackoverflow.com/questions/48490770/asking-user-input-with-for-loop/48490830 https://stackoverflow.com/questions/14869722/how-to-add-all-the-user-inputs-in-a-while-loop