python homework question

Posted February 3, 2018 1.3k views

i have one question which i could not able to solve ,if anybody please help me to solve this question,it would be greate help from your side, thank you

iam using windows in my home python 2.7.13 and in workplace iam using ubuntu python version 2.7.12
i have a list of number 1 to 10
first print the number
then prompt should ask the user please select your number
if the user select number 6 then except number 6 all other number should display,but number 6 should not dispaly

edited by AHA

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hi there! Sounds like you’re learning Python. There are a lot of great resources out there to help you get started. Dive Into Python is a favorite of mine and available for free online. In fact there are quite a few introductory Python tutorials right here on the DigitalOcean community site. We even compiled them into a free ebook:

Here’s a hint to point you in the right direction: You can prompt a user and capture their input using the builtin input function. For example:

>>> number = input("Choose a number between 1 and 10.\n")
Choose a number between 1 and 10.
>>> print(number)

After getting that input, you could use a “for loop” to iterate over your set of numbers, comparing them to the input. Then using a conditional statement, if the number doesn’t match, print it. If it does match, just move one to the next.

Hope that helps point you in the right direction!

by Lisa Tagliaferri
This tutorial will take you through writing conditional statements in the Python programming language.