Give a segment of python code that will print the numbers 1 to 7, each one on a new line

for x in range(1,8) : print(x) The range(1,8) function gives us an array of numbers from 1 to 7. The number on the right is the upper bound of the numbers which is why only 1 to 7 is returned.From here, a for loop is used, basically saying for each number inside the array, print this number.

JC

Related Python Mentoring answers

All answers ▸

Write a python function that takes a string as parameter and returns the character in the string with the most occurrences, along with the number of times this character occurs


Define a function that takes in the age of the user and adds it to an output sentence such as "You are ..... old".


What is the outcome of the following code? print(2*[3,4,5])


What is the difference between DFS and BFS? Where can I apply each?