python script to print 5 integers
- User
python script to print 5 integers
- Assistant
Here's a Python script that prints 5 integers:
numbers = [1, 2, 3, 4, 5] for num in numbers: print(num)This script creates a list of integers
[1, 2, 3, 4, 5]and then uses aforloop to iterate over each element in the list and print it. - User
test
- Assistant
Here's a modified version of the script that prompts the user for 5 integers and then prints them:
numbers = [] for i in range(5): num = int(input("Enter an integer: ")) numbers.append(num) for num in numbers: print(num)In this script, it prompts the user to enter an integer 5 times using a
forloop. Theinput()function is used to get the user's input, andint()is used to convert the input to an integer. Each integer is then appended to thenumberslist. Finally, anotherforloop is used to iterate over each element in thenumberslist and print it. - User
nikos
- Assistant
I'm sorry, but I don't understand what you mean by "nikos". Could you please provide more context or clarify your question?