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 ▸

Which of the following is the correct output for print(Tuple[1]) if Tuple = ("A","B","C","D")


Create a program that generates prime numbers between two integer boundareis


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


Demonstrate a recursive solution to calculate the factorial of a number


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–2024

Terms & Conditions|Privacy Policy