Note that negative indices can be used to access characters starting from the right-most character of the string, instead of the leftmost. Ex alphabet[-1] is 'Z'. zyDE 3.1.2: String indexing. Try the simple program that looks up the indices of letters in the alphabet. Try entering a negative value like -1, or -25. Load default template... 2 1 alphabet "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 2 3 user_number = int(input('Enter number to use as index: ')) 4 print ( 5 6 print('\nThe letter at index', user_number, 'of the alphabet is', alphabet [user_number]) 7 8 Run Enter number to use as index: The letter at index 2 of the alphabet is C

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter7: Characters, Strings, And The Stringbuilder
Section: Chapter Questions
Problem 12RQ
icon
Related questions
Question
Note that negative indices can be used to access characters starting from the right-most character of the string, instead of the leftmost. Ex:
alphabet[-1] is 'Z'.
zyDE 3.1.2: String indexing.
Try the simple program that looks up the indices of letters in the alphabet. Try entering a negative value like -1, or -25.
Load default template...
2
1 alphabet
2
819
3 user_number
4 print()
5
6 print('\nThe letter at index', user_number, 'of the alphabet is', alphabet [user_number])
7
=
Run
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
int(input('Enter number to use as index: '))
=
Enter number to use as index:
The letter at index 2 of the alphabet is C
1
Transcribed Image Text:Note that negative indices can be used to access characters starting from the right-most character of the string, instead of the leftmost. Ex: alphabet[-1] is 'Z'. zyDE 3.1.2: String indexing. Try the simple program that looks up the indices of letters in the alphabet. Try entering a negative value like -1, or -25. Load default template... 2 1 alphabet 2 819 3 user_number 4 print() 5 6 print('\nThe letter at index', user_number, 'of the alphabet is', alphabet [user_number]) 7 = Run "ABCDEFGHIJKLMNOPQRSTUVWXYZ" int(input('Enter number to use as index: ')) = Enter number to use as index: The letter at index 2 of the alphabet is C 1
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,