Whats the output of "for i in "hello world": print(i)" and why/how is this achieved

output is: "h", "e", "l", "l", "o", " ", "w", "o", "r", "l", "d" each character being printed in a new lineA "for" loop is used to itterate over a string "hello world" and print each character, this works by "moving" variable "i" along the string, giving it a different character per every iteration of a loop and then asking to print the value its currently holding

Answered by Python tutor

3926 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

What is the difference between a FOR loop and WHILE loop and how do I write them?


Write a function that takes a string, and outputs that string formatted in camelcase. (alternating upper and lower case for each character, e.g. cAmElCaSe)


Create a program that checks for syntactical errors in an email address.


Write a simple number guessing game, give the user 3 tries to guess a number between 1 and 10


We're here to help

contact us iconContact ustelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo

MyTutor is part of the IXL family of brands:

© 2026 by IXL Learning