import random
def main():
string = input("Enter a string: ")
index = random.randint(0, len(string) - 1)
character = string[index]
print("The character at index {} is {}".format(index, character))
if __name__ == "__main__":
main()
Приклад
Enter a string: Hello, world!
The character at index 5 is ,
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
import random
def main():
string = input("Enter a string: ")
index = random.randint(0, len(string) - 1)
character = string[index]
print("The character at index {} is {}".format(index, character))
if __name__ == "__main__":
main()
Приклад
Enter a string: Hello, world!
The character at index 5 is ,