Nowy kurs! Każdy programista powinien nauczyć się Generative AI!
Wypróbuj darmową lekcjęDyskusje Q&A
nums
0 głosów
1 Odpowiedźprogram prints multiple nums
0 głosów
4 odpowiedziHow do I sum nums in a range
0 głosów
2 odpowiedziImport random
0 głosów
16 odpowiedziWhy this code runs?:
nums = [4, 5, 6]
msg = "Numbers: {} {}". format(nums[0], nums[1], nums[2])
print(msg)
Numbers:4, 5.
Byt the code:
nums = [4, 5, 6]
msg = "Numbers: {} {} {} {}". format(nums[0], nums[1], nums[2])
print(msg)
leading to error?
IndexError: tuple index our of range
1 Głos
3 odpowiedziI dont unserstand the output if this code :
# string formatting
nums = [4, 5, 6]
msg = "Numbers: {0} {0} {2}". format(nums[0], nums[1], nums[2])
print(msg)
4 4 6
but when I do :
# string formatting
nums = [4, 5, 6]
msg = "Numbers: {0} {0} {2}". format(nums[1], nums[1], nums[2])
print(msg)
it gives me
5 5 6
is there a priority in the Reading ?
0 głosów
5 odpowiedziPopularne dzisiaj
Code
2 Votes
Solution
0 Votes
Calculator
0 Votes
How to make animation
0 Votes
Sololearn logo
0 Votes