Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- numeri = list(map(int, input("Scrivi i numeri separati da spazio: ").split()))
- somma = sum(n if i % 2 == 0 else -n for i, n in enumerate(numeri))
- somma_str = ''.join(f" {'+-'[i%2]} {n}" for i, n in enumerate(numeri))
- print(f"{somma_str[3:]} = {somma}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement