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

February 3, 2018 198 views
API Ubuntu

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

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.
2
>>> print(number)
2

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!

This tutorial will take you through writing conditional statements in the Python programming language.
Have another answer? Share your knowledge.