sum = 0
text = "fez"
nums = [1,2,3]
for i in range(0, len(text)):
sum = sum + nums[i]
print(sum)
6
sum = 0
text = "fez"
for letter in range(0, len(text)):
sum += letter
print(sum)
3
word = ""
myList = ["c","o","d","e","f","e","z"]
for letter in myList:
word += letter
print(word)
codefez
word = ""
myList = ["c","o","d","e","f","e","z"]
for i in range(0,4):
word += str(i)
print(word)
0123
word = ""
myList = ["c","o","d","e","f","e","z"]
for i in range(0,4):
word += myList[i]
print(word)
code
text = "hweolrllod"
word1, word2 = "", ""
for i in range(0, len(text), 2):
word1 = word1 + text[i]
print(f"word1: {word1}, word2: {word2} ")
word1: hello, word2:
text = "hweolrllod"
word1, word2 = "", ""
for i in range(0, len(text), 2):
word1 = word1 + text[i]
for j in range(1, len(text), 2):
word2 = word2 + text[j]
print(f"word1: {word1}, word2: {word}")"
word1: hello, word2: worldworldworldworldworld
text = "hweolrllod"
word1, word2 = "", ""
for i in range(0, len(text), 2):
word1 = word1 + text[i]
for j in range(1, len(text), 2):
word2 = word2 + text[j]
print(f"word1: {word1}, word2: {word2}")
word1: hello, word2: world
word = ""
myList = [1,2,3,4,5,6,7,8,9,10]
for i in range(0, len(myList)):
word = word + str(myList[i])
sum += myList[i]
print(f"word: {word}")
word: 12345678910
word, sum = "",0
myList = [1,2,3,4,5,6,7,8,9,10]
for i in range(0, len(myList)):
word = word + str(myList[i])
sum += myList[i]
print(f"word: {word}, sum: {sum}")
word: 12345678910, sum: 55