Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Draft saved
Draft discarded
Cancel
5
  • 2
    Instead of using input(), can you hardcode a known input that fails? Commented Mar 15, 2020 at 0:37
  • sorry, I just edited it ! Commented Mar 15, 2020 at 0:41
  • Please give us a minimal, reproducible example; don't expect every one of us to type input for you. Commented Mar 15, 2020 at 0:42
  • What is this program supposed to do? Why do you expect other output? It obviously works the way you programmed it -- computers are rather annoying in that respect. Commented Mar 15, 2020 at 0:43
  • @harveychoi this is actually an interesting question, but you've made it hard to understand. You can show a minimal example with just: a[a.index(1)], a[a.index(2)] = a[a.index(2)], a[a.index(1)] — you don't need all the input() business — and then simply ask why it is not swapping elements as you might expect. Commented Mar 15, 2020 at 0:48

lang-py

AltStyle によって変換されたページ (->オリジナル) /