fork download
  1. # Get user input for n and dice number
  2. n = int(input())
  3. dice_number = int(input())
  4.  
  5. # Convert n to a string to easily access each digit
  6. n_str = str(n)
  7.  
  8. # Check if the dice number is even or odd
  9. if dice_number % 2 == 0:
  10. # Print the digits at odd places in n
  11. print()
  12. for i in range(len(n_str)):
  13. if (i + 1) % 2 != 0:
  14. print(n_str[i], end=" ")
  15. print()
  16. else:
  17. # Print the digits at even places in n
  18. print("Digits at even places in n: ")
  19. for i in range(len(n_str)):
  20. if (i + 1) % 2 == 0:
  21. print(n_str[i], end=" ")
  22. print()
Success #stdin #stdout 0.04s 9772KB
stdin
1234
2
stdout
1 3