[Question]
  [
## Background
Hello is a language "written" by [Anne Veling](https://esolangs.org/wiki/Anne_Veling), which errors if the program does not contain only `h`, and will print `Hello World` for every `h`
## Task
You are to write an interpreter/compiler for Hello.
## Example in Python
```
import os
i = input("Program: ")
for a in i:
    if a != 'h':
        print("err")
        quit()
    else:
        print("Hello World")
```
## Details
* If the program is not only `h`s, it must print `err` or `error` (case-insensitive)
* It's okay if you print "Hello World"s before your program discovers a non-`h` character and errors, however, the program must halt if a non-`h`
* You may throw an error, as long as you print `err`/`error` before throwing, or by using a custom error builtin, like `raise SyntaxError('err')` in python. (basically, you have to **purposefully** error with `err`/`error`
* Assume the program will not be empty
* Output can have a trailing newline, space, or nothing to separate `Hello World`s
* If a program has multiple lines, it should error (due to `\n` not being an `h`)
* You can assume that input will always be ASCII 33-126 and 10 (decimal)
* The `h`s are case sensitive (so `H` is not a valid program)
instruction is found
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), shortest answer wins
## Test cases
```
Input:
h
Output:
Hello World
Input:
hhhhhh
Output:
Hello WorldHello WorldHello WorldHello WorldHello WorldHello World
(again, it doesn't matter whether it's spaces, newlines, or nothing to separate `Hello World`s
Input:
rubbish
Output:
err
Input:
huh
Output:
Hello Worlderr
Or
err
```
First challenge so please have mercy
  
[Answer]
# [Lenguage](https://esolangs.org/wiki/Lenguage), \$1.42 \times 10^{122}\$ bytes
*minus a lot of bytes thanks to Kevin Cruijssen and Bubbler*
```
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh...
```
This is 142099843608359281286315447494338058415442968773543757980908246691462388164856076679905341690709953072132211450166077106439 `h`s, which also makes it a valid Hello program, though not one you'd want to run. The original brainfuck code is ~~140~~ 135 bytes:
```
,[>-[<-->-----]+<--[>]>[[-->-[>>+>-----<<]<--<---]>-.>>>+.>>..+++.>>.>.<<<.+++.------.<<-.[>]>>>>,>]<]<[[>++<+++++]>-.+++++++++++++..>]
```
[Try it online!](https://tio.run/##TUxJDoBACHsQwgtIP0I4qNGMMfHg@vwRxos9AF3osPfLNl/jWmtnYFNmcMIpToPDLCUD6DNUPRzNCFgQegwRorYhqtpIC3NQlqwJdPD4NQORUiIL6A8ReK2llKf053QfLw "brainfuck – Try It Online")
This prints Hello World every time it sees a `h` through a modification of the [shortest known Hello, World! program](https://codegolf.stackexchange.com/a/163590/76162), stopping the loop and printing `err` if it sees anything other than a `h`.
[Answer]
# [Python 3](https://docs.python.org/3/), 49 bytes
```
lambda s:{*s}-{'h'}and'err'or'Hello World'*len(s)
```
[Try it online!](https://tio.run/##HcGxCoMwEADQ3a/IdongUNyE7v0DF5eERC5wXsIlIkX89iv0vfrtWHjW/b0p@SNEb9pyj@2ZbkB4PEdIIlAEPomomLUIRRgpsW1OL8yUzGupkrnb3WauZ7fOOcUB/wY5Q8gN9Qc "Python 3 – Try It Online")
**Python 2, 51 bytes**
```
lambda s:s.strip('h')and'err'or'Hello World'*len(s)
```
[Try it online!](https://tio.run/##HcHBCsIwDADQ@76itzQeBD0OvPsHXgRpaUcKMS1Jx9jXR/C9cU7qcvft8XZO31xSsNWuNrWNCASYpEBVha7wrMw9vLpygQtXiYZ@UOMabuvQJjNuUdPxaTL2GRHRaaG/Rfecm5H/AA "Python 2 – Try It Online")
**Python 2, 51 bytes**
```
lambda s:['err','Hello World'*len(s)]['h'+s==s+'h']
```
[Try it online!](https://tio.run/##HcaxCsIwEADQvV@R7RLromMhu3/g0BZJaMoFziTcpRS//hTf9NqnYy133f2iFN5xC0amGRIzXOGRiKp5VqYNLpSKFbfOgDCK9zL@suqJmZK5TY1z6Xa3HM5XLu3o1jmnOODfwEeMWVC/ "Python 2 – Try It Online")
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 32 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319 "When can APL characters be counted as 1 byte each?") ([SBCS](https://github.com/abrudz/SBCS ".dyalog files using a single byte character set"))
Anonymous tacit prefix function.
```
{'h'=⍵:'Hello World'⋄-⎕←'err'}⍤0
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///qG@qp/@jtgkG/6vVM9RtH/VutVL3SM3JyVcIzy/KSVF/1N2iC1QDVKGeWlSkXvuod4nB/zQg91Fv36Ou5ke9ax71bjm03vhR20SgsuAgZyAZ4uEZ/D9NAWgel7o6F4gBAkgcDxjbQx0A "APL (Dyalog Unicode) – Try It Online")
`{`…`}⍤0` replace each character (`⍵`) with the result of applying the following lambda to it:
 `'h'=⍵:` if the character is `h`:
  `'Hello World'` return the required phrase
 `⋄` else:
  `⎕←'err'` print `err`  
  `-` negate it (causing an error and terminating)
[Answer]
# [R](https://www.r-project.org/), 76 bytes
```
function(p,n=nchar(p))ifelse(p==strrep('h',n),strrep("Hello World",n),'err')
```
[Try it online!](https://tio.run/##RYxBDoAgDATvvsJwoU34And/4FmxBJOmkIrvR1ET97Qzya62RMzZt3hKqHsWKE68hLQoFMQ9Eh8ExfujqlIBm6wTdB@ZqY/HOStvpntLqhbfTzAGh6@lJz@vTDe1Cw "R – Try It Online")
Should be a comment on <https://codegolf.stackexchange.com/a/210520/98085> - I didn't realise you could do functions like that! Slight change to be more robust when n = 0 and to use direct comparison rather than regex. -1 byte thanks to <https://codegolf.stackexchange.com/users/90265/zippymagician>.
Bonus version with side-effects (like redefining subtraction) thanks to <https://codegolf.stackexchange.com/users/92901/dingus>.
# [R](https://www.r-project.org/), 71 bytes
```
{`-`=strrep;function(p,n=nchar(p))`if`(p=='h'-n,'Hello world'-n,'err')}
```
[Try it online!](https://tio.run/##K/qfkZqTk2/7vzpBN8G2uKSoKLXAOq00L7kkMz9Po0AnzzYvOSOxSKNAUzMhMy1Bo8DWVj1DXTdPR90DpE@hPL8oJwXMTy0qUteshRinoaSkyQVlZYABgp@Ukwrk/QcA "R – Try It Online")
[Answer]
# [Gema](http://gema.sourceforge.net/), 23 characters
```
h=Hello World
?=err@end
```
Sample run:
```
bash-5.0$ echo -n 'hohoho' | gema 'h=Hello World;?=err@end'
Hello Worlderr
```
### Gema (old version with err on empty code), 32 characters
```
\A\Z=err
h=Hello World
?=err@end
```
[Try it online!](https://tio.run/##S0/NTfz/P8PWIzUnJ18hPL8oJ4XL3ja1qMghNS8FKJEPggA "Gema – Try It Online") / [Try all test cases online!](https://tio.run/##nVDBSsQwED03XzGGuukeStSLBwmuB0FPghcPbVnaZtYWa1KSFIR1v70mKegqeNAcZl4mb2beS1PbbpbYDrVByG/AoXXbtrYoMpIUrGOVYHc4DBqetBkki8V4frz8E8aBZmqa3saJaAwja0JG0yu3A/YOp/n5mYWQL7/nCx9LxYDdq3FyPj@inYYAbt9GbB1KDx9eGCE7baAPJB@BpvuTT5fFpjrQK5CaJCZ2C5pmgG2nIQ/U2EX9Nq5Hx5/xtebWtBEAmztx5IRcCy9@g0rODNaUkOQPHryouIrzlPk7L0t1oL66iApo/6V5UVVFQgZFccQT4jdqVcFqtTgLnxIUSq1w/gA "Bash – Try It Online")
[Answer]
# x86-16 machine code, IBM PC DOS, ~~41~~ 40 bytes
Binary:
```
00000000: be82 00ba 1801 b409 ac3c 0d74 0a3c 6874  .........<.t.<ht
00000010: 02b2 24cd 2174 f1c3 4865 6c6c 6f20 576f  ..$.!t..Hello Wo
00000020: 726c 6424 6572 7224                      rld$err$
```
Listing:
```
BE 0082         MOV  SI, 82H            ; SI to DOS PSP 
BA 0118         MOV  DX, OFFSET HW      ; point to 'Hello World' string 
B4 09           MOV  AH, 9              ; DOS write string function 
            CHAR_LOOP: 
AC              LODSB                   ; AL = next input byte 
3C 0D           CMP  AL, 0DH            ; is a CR (end of input string)? 
74 0A           JZ   DONE               ; if so, end 
3C 68           CMP  AL, 'h'            ; is an 'h'? 
74 02           JZ   WRITE_STR          ; if so, write Hello(s)
B2 24           MOV  DL, LOW OFFSET ER  ; otherwise, point to 'err' string 
            WRITE_STR: 
CD 21           INT  21H                ; write string to stdout 
74 F1           JZ   CHAR_LOOP          ; if 'h', keep looping 
            DONE:
C3              RET                     ; return to DOS 
            HW  DB  'Hello World$'
            ER  DB  'err$'
```
Standalone PC DOS executable COM program. Input via command line. This version prints `Hello Worlderr` if an error is in the input code.
[![enter image description here](https://i.stack.imgur.com/Bhhx2.png)](https://i.stack.imgur.com/Bhhx2.png)
And for fun (and since I did it first), this version will only print `err` if an error is in the code.
### x86-16 machine code, IBM PC DOS, ~~47~~ ~~45~~ 44 bytes
Binary:
```
00000000: bf80 00ba 1c01 8a0d 4951 abb8 6809 f3ae  ........IQ..h...
00000010: 5974 04b2 28b1 01cd 21e2 fcc3 4865 6c6c  Yt..(...!...Hell
00000020: 6f20 576f 726c 6424 6572 7224            o World$err$
```
Listing:
```
BF 0080         MOV  DI, 80H            ; DI to DOS PSP 
BA 011C         MOV  DX, OFFSET HW      ; point to 'Hello World' string 
8A 0D           MOV  CL, BYTE PTR[DI]   ; CL = input length 
49              DEC  CX                 ; remove leading space from length 
51              PUSH CX                 ; save length for later 
AB              STOSW                   ; DI to start of command line input
B8 0968         MOV  AX, 0968H          ; AL = 'h', AH = 9 
F3/ AE          REPZ SCASB              ; search input for 'h': ZF if Hello, NZ if error
59              POP  CX                 ; restore input length 
74 04           JZ   HELLO_LOOP         ; if no error, write Hello(s) 
B2 28           MOV  DL, LOW OFFSET ER  ; otherwise, point to 'err' string 
B1 01           MOV  CL, 1              ; only show 'err' once 
            WRITE_LOOP: 
CD 21           INT  21H                ; write string to stdout 
E2 FC           LOOP WRITE_LOOP         ; loop until done 
C3              RET                     ; return to DOS 
            HW  DB  'Hello World$'
            ER  DB  'err$'
```
[![enter image description here](https://i.stack.imgur.com/c7LbM.png)](https://i.stack.imgur.com/c7LbM.png)
Props:
* -1 byte for both thanks to @MatteoItalia for suggestion to change only the low byte on the error string pointer.
[Answer]
# Excel, 63 bytes
```
=IF(SUBSTITUTE(A1,"h","")="",REPT("Hello World",LEN(A1)),"err")
```
---
`SUBSTITUTE(A1,"h","")=""` returns `TRUE` iff `A1` contains nothing but `h`.
`REPT("Hello World",LEN(A1))` repeats the string for however many characters are in `A1`.
`=If(Substitute(~)="",REPT(~),"err")` returns the repeated string if `A1` contains only `h` and `err` if it contains anything else.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 17 bytes
14 if we can print `Err` as a substring of the output (e.g. `“½,⁾ẇṭ»€!fƑ?”h` [TIO](https://tio.run/##ASwA0/9qZWxsef//4oCcwr0s4oG@4bqH4bmtwrvigqwhZsaRP@KAnWj///9oaHhoaA)).
```
“½,⁾ẇṭ»€“¹ṫ»fƑ?”h
```
**[Try it online!](https://tio.run/##y0rNyan8//9Rw5xDe3UeNe57uKv94c61h3Y/aloDEtv5cOfqQ7vTjk20f9QwN@P///8ZGRUZGQA "Jelly – Try It Online")**
### How?
```
“½,⁾ẇṭ»€“¹ṫ»fƑ?”h - Main Link: program
               ”h - set right argument to 'h'
              ?   - if...
             Ƒ    - ...condition: is (program) invariant under?:
            f     -     keep only ('h's)
       €          - ...then: for each (c in program):
“½,⁾ẇṭ»           -     "Hello World"
        “¹ṫ»      - ...else: "error"
                  - implicit, smashing print
```
[Answer]
# [Ruby](https://www.ruby-lang.org/) `-0p`, ~~42...35~~ 33 bytes
*The idea to use the `-0p` flags (instead of `-n` like I originally had) came from [@DomHastings's Perl answer](https://codegolf.stackexchange.com/a/210509/92901), saving 4 bytes.*
```
$_=/[^h]/?:err:'Hello World'*~/$/
```
[Try it online!](https://tio.run/##KypNqvz/XyXeVj86LiNW394qtajISt0jNScnXyE8vygnRV2rTl9F////jIyMf/kFJZn5ecX/dQ0KAA "Ruby – Try It Online")
Reads the program from STDIN. A regex is used to check whether the program contains any character other than `h`. If so, print `err`; otherwise, print `Hello World` as many times as the number of characters in the program (given by `~/$/`).
Using a bare regex literal as a boolean is a deprecated Perlism that (since Ruby 1.9) only works with the `-n` or `-p` flags.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 17 bytes
```
'hÃQig”Ÿ™‚ï”×ë'‰ë
```
[Try it online!](https://tio.run/##yy9OTMpM/f9fPeNwc2Bm@qOGuUd3PGpZ9Khh1uH1QM7h6YdXqz9q2HB49f//SkpKGVwZGUAKAA)
Big thanks to @Kevin for your [dictionary compression tool](https://codegolf.stackexchange.com/a/166851/78850)!
And once again, Kevin has struck and managed to shave 3 bytes from my answer! So the aforementioned thanks is to be multiplied by a massive magnitude.
## Explained (old)
```
Ð'hÃQig”Ÿ™‚ï”и»ë"err
Ð                       # Triplicate the input. STACK = [input, input, input]
 'h                     # Push the letter 'h'. STACK = [input, input, input, 'h']
   Ã                    # Keep _only_ the letter h in the input. STACK = [input, input, input.keep('h')]
    Q                   # Compare this with the original input. STACK = [input, 1 OR 0]
     i                  # If the comparison is truthy (i.e. it's only h's):
      g                 #   Push the length of the input. STACK = [len(input)]
       ”Ÿ™‚ï”           #   Push the compressed string "Hello World". STACK = [len(input), "Hello World"]
             и»         #   Repeat that string length of input times and join upon newlines. STACK = ["\n".join("Hello World" * len(input))]
               ë        # Else:
                "err    #   Push the string "err" to the stack. STACK = [input, "err"]
                        # Implicitly output the top of the stack
   
         
```
[Answer]
# Haskell (Hugs 2006), 31 bytes
```
mapM(\'h'->putStr"Hello World")
```
Pending a question to the OP r.e. "error" in a larger error message.
The spec says "it must print err or error", which it does on Hugs 2006, specifically the `Raskell 1.0.13 interpreter based on Hugs 2006`:
```
> mapM(\'h'->putStr"Hello World") "huh"
Hello World
Program error: pattern match
failure: ww_v4136 'u'
```
[Answer]
# [Arn](https://github.com/ZippyMagician/Arn), [24 bytes](https://github.com/ZippyMagician/Arn/wiki/Carn)
```
ùÝ└ån<⁼aLw$■v&Z(#▄╗└·I╔║
```
[Try it!](https://zippymagician.github.io/Arn?code=KCR7PSJoIn0pIz0jJiYneXQgYnMnXiN8fCJlcnI=&input=aApoaGhoaGgKcnViYmlzaA==)
# Explained
Unpacked: `(${="h"})#=#&&'yt bs'^#||"err`
And this is why I need to add an if else...
```
      (              Begin expression
        $            Filter
          {          Block with index of _
              _      Implicit
            =        Equals
              "h"    String
          }          End block
          _          Variable initialized to STDIN; implied
      )              End expression
    #                Length
  =                  Equals
      _              Implied
    #
&&                   Boolean AND
    'yt bs'        Compressed string equal to "Hello World"
  ^                  Repeated
      _              Implied
    #
||                   Boolean OR
  "err
```
[Answer]
# [SNOBOL4 (CSNOBOL4)](http://www.snobol4.org/csnobol4/), 94 bytes
```
	I =INPUT
	I NOTANY('h')	:S(E)
	OUTPUT =DUPL('Hello World',SIZE(I))	:(END)
E	OUTPUT ='err'
END
```
[Try it online!](https://tio.run/##K87LT8rPMfn/n9NTwdbTLyA0hAvI8vMPcfSL1FDPUNfktArWcNXk4vQPDQFKKti6hAb4aKh7pObk5CuE5xflpKjrBHtGuWp4agKVarj6uWhyucIVq6cWFalzAQX///dwBQA "SNOBOL4 (CSNOBOL4) – Try It Online")
```
	I =INPUT					;* Read input
	I NOTANY('h')	:S(E)				;* If there is a character that's not 'h' in the input, goto E
	OUTPUT =DUPL('Hello World',SIZE(I))	:(END)	;* else print "Hello World" repeatedly and goto END
E	OUTPUT ='err'					;* print 'err'
END
```
[Answer]
# JavaScript, 49 bytes
-4 bytes if we can *throw* an error instead of outputting a string.
```
f=([c,...a])=>c?c==`h`?`Hello World`+f(a):`err`:a
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/f8/zVYjOllHT08vMVbT1i7ZPtnWNiEjwT7BIzUnJ18hPL8oJyVBO00jUdMqIbWoKMEq8X9yfl5xfk6qXk5@ukaahlKGkqYmF7oYCGAVr8Aq7gEU@w8A)
[Answer]
## JavaScript ~~72~~ 66 bytes
-6 bytes thanks to @Ismael Miguel
```
alert(/^h*$/.test(a=prompt())?a.replace(/h/g,'Hello World'):'err')
```
[Answer]
# [flex](http://web.mit.edu/gnu/doc/html/flex_1.html), ~~76~~ \$\cdots\$ ~~55~~ 52 bytes
```
%%
h puts("Hello World");
[^h] puts("err");exit(1);
```
Put the above code in a file called `hello.l` and make the interpreter with:
```
flex hello.l && gcc lex.yy.c -o hello -lfl
```
Trying it on my terminal:
```
> echo -n hhh|./hello.exe
Hello World
Hello World
Hello World
```
With newline:
```
> echo hhh|./hello.exe
Hello World
Hello World
Hello World
err
```
notice the `err` because of the trailing newline `echo` normally sends.
With non-`h` character:
```
> echo -n hhhehhh|./hello.exe
Hello World
Hello World
Hello World
err
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~71~~ 65 bytes
```
f(char*p){p=*p-'h'?*p&&puts("err"):f(p+1)||!puts("Hello World");}
```
[Try it online!](https://tio.run/##VY7NDoIwEITvfYq1RmlRTLyK4tUHMPHiASg/bVKgacsJeHYskKjsaWd28s2yoGRsHAvCeKJ9RTt181Xgce/uq/1etdYQnGuN6aUg6nCmfb9ZzEcuZQOvRssM03AYn7mxQGDGgNJNqZMKaIfcLmpbAMFRFO9M/K7x8XcPERRkJRe6Q6IBoa2omWyzHK7GZqI58Qg5GFSJqAkFB19aMZ/yXzHNv6HbNBVmnZm@n0vGDw "C (gcc) – Try It Online")
* Thanks to @rtpax for saving 6!
`f(char*p){p=` - function tacking a `program` and returning with the eax trick, reusing `p`.  
Calls itself recursively.  
Recursion happens before `program` execution so if all steps are correct a `false` value is returned and the `program` is executed.  
If there's an error a `truthy` value is returned and `program` is not executed at all, an error message is displayed.
```
*p-'h'? `...` :f(p+1)||!puts("Hello World");
 - check each character in ***program*** : if ***h***  continue recursion and
   if result is ***false*** program do its job.
***p*** is ***true***  if there was an error, ***false*** instead.
 - if not ***h*** stop recursion and :
*p            - if end of ***program*** 
***p***  is ***false***
&&puts("err") - if not end of ***program*** display error
***p***  is ***true***.
```
---
[~~61~~ 58 bytes](https://tio.run/##VU9BDoIwELz3FZs1YotiYuJJTL36ABMvHoBCoUmBpoUT4e0VMFHZ08zs7ExWRKUQ3ksqqtSGhg2hCQLTd46GJtpVuxsW1uIF74XWLTxbq3Nk/BwEkpr9icWjfxSuAwrLPRjbljatgQ1kwqrpJFDkPNm65NXg4bePCUi6oksp4gRHQjaqEbrPC7i6LlftseJkCoM6VQ1lMIV/WrGa/V8yz79g@yxTbu2Z/1hK/Bs "C (gcc) – Try It Online") alternative less interesting solution which runs the program and stops when an error happens
```
f(char*p){*p&&puts(*p-'h'?"err":"Hello World")>4&&f(p+1);}
```
* Saved 3 thanks to @rtpax !
[Answer]
# [Python 3](https://docs.python.org/3/), 52 bytes
```
lambda x:(x=='h'*len(x))*len(x)*'Hello World'or'err'
```
[Try it online!](https://tio.run/##LcYxDsMgDEDRvafwZjtDlm6V2HuDLFmoIALJwcgwkNOTDP3L@/XqSct7HuBgn@LPX/AwPjScw4SLxEKD@e@C3yiisKlJQDWMZjjzWdU6tKu9quXS6aDn19ZDLqtFH4iZZ3q6AQ "Python 3 – Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/), 58 bytes
```
lambda s:s and s=="h"*len(s)and"Hello World"*len(s)or"err"
```
[Try it online!](https://tio.run/##NcoxCsMwDEDR3acQnuwOWboVvPcGXbq4yCECRTaSOuT0Tlvo9nn8cfjW5TrX8pxc9xdWsJtBFQQrJW7xwk2S5Q/Ee2Pu8OjK@OeusanGSfvo6mCHBZLxdijfXsyRZNFWkUlaCENJPK3p96Sc8zwB "Python 3 – Try It Online")
[Answer]
# [Japt](https://github.com/ETHproductions/japt), ~~23~~ 19 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
-4 bytes thanks to @Shaggy
```
rh ?`r`:¡`HÁM Wld
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=cmggP2CAcmA6oWBIwU0gV45sZA&input=Imgi)
## Explanation
```
rh ?`...`:¡`...
   ?              // if
rh                //   input with 'h' removed
    `...`         // then "err"
         :        // else
          ¡       //   each char in input
           `...   //   replaced with "Hello World"
```
[Answer]
# [Pip](https://github.com/dloscutoff/pip), ~~28~~ 27 bytes
```
aRM'h?"err""Hello World"X#a
```
-1 byte from DLosc.
If the string without h's is empty, print "Hello World" required number of times.
Otherwise, error.
This program errors on empty input as well.
[Try it online!](https://tio.run/##K8gs@P8/MchXPcNeKbWoSEnJIzUnJ18hPL8oJ0UpQjnx////GRCQAwA "Pip – Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/), ~~57~~ 52 bytes
```
lambda a:a=='h'*len(a)and'Hello World'*len(a)or'err'
```
[Try it online!](https://tio.run/##VckxDoMwDEDRnVN4c8LKVik7N@jSxVWCHGFs5EZCPX3KgirG9//@bWw69SW9utD2zgT0oJSQcZSigSJpxrmIGDzNJV/ZHIs79t2rtrAEZGaMcfj7psb1A0cVAbUGh/l67v4D)
[Answer]
# [Vim](https://www.vim.org), ~~48~~ 47 bytes
*Thanks to @DLosc for -1 bytes*
```
:g/\_$\_^\|[^h]/norm HcGerr
:s/h/Hello World/g
```
[Try it online!](https://tio.run/##K/v/3ypdPyZeJSY@LqYmOi4jVj8vvyhXwSPFPTO1qIjLqlg/Q98jNScnXyE8vygnRT@d6///DBQAAA "V (vim) – Try It Online")
The `:g` command is a bit convoluted, but there's a reason for that. The `[^h]` part will match all non-`h` characters, but it won't match newlines. `$` or `\n` will match end-of-line, which means they will match a single line without a newline. To make it match only when there are multiple lines, I used `\_$\_^`. This will only match newlines (`\_$`) that are followed by another line (`\_^`).
For some reason, this doesn't work properly in TIO, so programs where the only non-`h` characters are newlines won't error. However, this does work properly in Vim.
Explanation:
```
:g/    (x)     /     (y)     # If x exists, execute y:
   \_$\_^                    #  x -> An end-of-line followed by a start-of-line;
         \|[^h]              #   OR any character that isn't 'h'
                norm HcGerr  #  y -> Delete all lines, then print 'err'
:s/h/Hello World/g           # Replace every 'h' with 'Hello World'
```
[Answer]
# [MathGolf](https://github.com/maxbergmark/mathgolf/blob/master/math_golf.txt), ~~23~~ 20 [bytes](https://github.com/maxbergmark/mathgolf/blob/master/code_page.py)
```
'h-╛æ╖•p0{δ╕○ô 'W╕7ÿ
```
[Try it online.](https://tio.run/##y00syUjPz0n7/189Q/fR1NmHlz2aOu1Rw6ICg@pzWx5NnfpoevfhLQrq4UCm@eH9//8rZShxKWVkQMiYvAwwAeQUlSYlZRZnKAEA)
**Explanation:**
```
'h-                  '# Remove all "h" from the (implicit) input-string
   ╛                  # Pop, and if it's now truthy (thus non-empty):
    æ                 #  Use the following four characters as single code-block:
     ╖•p              #   Push compressed string "err"
        0             #   And push a 0
         {            # Either loop 0 times,
                      # or loop over each character of the (implicit) input-string:
          δ           #  Titlecase the implicitly pushed current character ("h"→"H")
           ╕○ô        #  Push compressed string "ello"
                      #  Push " "
               'W    '#  Push "W"
                 ╕7ÿ  #  Push compressed string "orld"
                      # (implicitly output the entire stack joined together as result)
```
[Answer]
# SimpleTemplate 0.84, ~~92~~ 63 bytes
This challenge was simple, yet fun!
Simply checks if the input is just "hhh...." and outputs the text, or outputs "err" to STDOUT:
```
{@ifargv.0 matches"@^h+$@"M}{@eachM.0}Hello World{@/}{@else}err
```
The big byte saving was due to [the-cobalt](https://codegolf.stackexchange.com/users/97771/the-cobalt)'s comment:
> 
> Outputting to STDOUT is fine, so you could use your 63 byte version.
> 
> 
> 
---
**Ungolfed:**
Below is a more readable version of the code:
```
{@if argv.0 matches "@^h+$@"}
    {@each argv.0 as h}
        {@echo "Hello World"}
    {@/}
{@else}
    {@echo "err"}
{@/}
```
---
You can try this on: <http://sandbox.onlinephpfunctions.com/code/e35a07dfbf6b3b56c2608aa86028b395ef457129>
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 44 bytes
```
$args|%{if($_-104){'err';exit}"Hello World"}
```
[Try it online!](https://tio.run/##K8gvTy0qzkjNyfmvkmZb/V8lsSi9uEa1OjNNQyVe19DARLNaPbWoSN06tSKzpFbJA6gwXyE8vygnRan2fy0Xl3oGCKjrKIGMyFcC0iAApIvzSwuUgAYphRRVZualK6jEK1gpWauppCk4xFurq9f@BwA "PowerShell – Try It Online")
Takes input by splatting
[Answer]
# Befunge-93, 58 56 bytes
```
~:1+!#v_"h"-#v_"dlroW olleH",,,,,,,,,,,  
  @,,,@#"err"<
```
[Try it online!](https://tio.run/##S0pNK81LT/3/v87KUFtRuSxeKUNJF0Sl5BTlhyvk5@SkeijpIICCApeCggOQ4aCslFpUpGTz/39GRgYA "Befunge-93 – Try It Online")
## How does it work?
```
~                         # Read a character.
:1+!                      # Check whether we read -1 (end of input);
                          # this leaves 1 on the stack if we are at 
                          # the end of the input, else 0.
#v_                       # Exit the program if we're at the end
 @                        # end of the input.
"h"-                      # Compare the read character with the
                          # character "h", if equal, we leave 0 on
                          # the stack, otherwise, non-zero.
          #v_             # If we read anything but "h", print "err"
@,,,@#"err"<              # and exit the program.
"dlroW olleH",,,,,,,,,,,  # Print "Hello World"
```
[Answer]
GFA Basic (Atari ST), 125 bytes
```
INPUT a$
FOR i=1 TO LEN(a$)
b$=MID$(a$,i,1)
IF b$="h"
PRINT "Hello World"
ELSE
PRINT "err"
EXIT IF 1
ENDIF
NEXT I
```
[Answer]
# [Io](http://iolanguage.org/), 63 bytes
```
method(:,:foreach(X,if(X!=104,"err"print-,"Hello World"print)))
```
[Try it online!](https://tio.run/##Jcm9CoAgFEDh3aewOykYFDQJ7b1BDi39KArmjZs9v4Wd8XwBi@N65Es5bfZ4CK20Q7Lr7oVRwQnTjH03KLBEcFFIuVUw2RiRz0jx@J@UsjgBvgaSMQBeISbGPqBn28L9SXkB "Io – Try It Online")
## Explanation
```
method(i,                         // Take input
    i foreach(X,                  // For every item:
        if(X!=104,                //     If the codepoint isn't 104:
             "err"print           //         print "err" (w/o nl)
                       -          //         Subtract "err" by the "Object" class (causes error)
             ,"Hello World"print  //     Otherwise, print "Hello World" (w/o nl)
)))
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~84~~ 80 bytes
-4 bytes thanks to [ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat). It's beautiful!
```
main(c,v)char**v;{*v[1]++-'h'?*--v[1]&&puts("err"):main(puts("Hello World"),v);}
```
[Try it online!](https://tio.run/##S9ZNT07@/z83MTNPI1mnTDM5I7FIS6vMulqrLNowVltbVz1D3V5LVxfEU1MrKC0p1lBKLSpS0rQCa4EIeKTm5OQrhOcX5aQoaQINsa79//9/RkZGIgA "C (gcc) – Try It Online")
Not so fancy, but I like that it's a complete program **`:)`**
"Normal" version:
```
#include <stdio.h>
int main(int argc, char** argv)
{
    if (*argv[1]++ - 'h')
        return *--argv[1] && puts("err");
    else
        return main(puts("Hello World"), argv);
}
```
]