Identifier ‘web3’ has already been declared despite web3 is undefined

I am connecting a html page to a Solidity contract and get contradicting errors.
If I comment out the line const web3 = new Web3(window.ethereum); the code works and it says web3 is undefined no error.
But when I uncomment const web3 = new Web3(window.ethereum); I get Identifier 'web3' has already....

What am I missing here?

Complete code here https://guess-number-q57u.onrender.com/

<script>//<- line 32
  if (typeof web3 === 'undefined') {
    console.log("web3 is undefined"); //prints-->web3 is undefined
  } else {
    console.log("web3 variable is defined and" + " value is " + web3);
  }

  //const web3 = new Web3(window.ethereum);//<-- when I uncomment this line I get: despite above web3 is undefined
  //(index):32 Uncaught SyntaxError: Identifier 'web3' has already been declared (at (index):32:9)