How do I get python to print a specific position within a range?

January 24, 2012 – 8:36 pm

The headline question does not justify what I am asking. However, what I am asking is how I get a program to print or display a a character of a certain position within a range. Like if I had
n = range(1,100). Obviously I can just type "print n" and get a sequence of numbers from 1 to 99. But I want to pinpoint a specific number by pointing out its position within the range. If I do not make sense, srry, im new to this.

Related posts:

  1. Can I print output based on a range in Python?
  2. How to print a position number from a file in Java?
  3. Python question, if i need to design a python program that has a range specified by the user, how do i count?
  4. Python: Reversing a string by changing the range of the for loop?
  5. is it possible to print the items in a python list sans the lowest?
  6. setting desktop icon position using python?
  7. Why is print a keyword in Python?
  8. What are other ways can i use instead of a print statement in python?
  9. Python, I am trying to print out a list of factorials starting at 0 and going to an inputed number.?
  10. In Python. Prompt the user for an input integer and then print the next 10 numbers?
  1. One Response to “How do I get python to print a specific position within a range?”

  2. The result of the range function is a list. You can specify the index just like any other list. For example:
    —-
    x = [5,6,7,8]
    print x[1]
    #output is 6

    print range(5,9)[1]
    #output is 6
    —-

    By ChaosGrimm on Jan 24, 2012

Sorry, comments for this entry are closed at this time.