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

Related Python Mentoring answers

All answers ▸

Create a program that takes in two numbers and returns the highest of the two


How do I use format python code?


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)


Given a list of N numbers, use a single list comprehension to produce a new list that only contains those values that are: (a) even numbers, and (b) from elements in the original list that had even indices .


We're here to help

contact us iconContact usWhatsapp logoMessage us on Whatsapptelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo

© MyTutorWeb Ltd 2013–2025

Terms & Conditions|Privacy Policy
Cookie Preferences