wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if c = 94 | if c == 94 | Use ==. | MATLAB |
process | process() | Add parentheses. | Swift |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
let num = 'hello' | let num = "hello" | Double quotes. | Swift |
def foo
puts 'world'
end | def foo
puts 'world'
end | Correct. | Ruby |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<p>world <b>world</p></b> | <p>world <b>world</b></p> | Nest properly. | HTML |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
let data = 71; let data = 87; | let data = 71; data = 87; | Duplicate declaration. | JavaScript |
{{'name':11, 'title' 15}} | {{'name':11, 'title':15}} | Colon missing. | Python |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
<br></br> | <br> | Self-closing. | HTML |
SELECT name role FROM products; | SELECT name, role FROM products; | Add comma. | SQL |
x > 28 & z < 8 | x > 28 and z < 8 | Use 'and' not '&'. | Python |
{{'title':'world'}} | {{"title":"world"}} | Use double quotes. | JSON |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
print('data') | print('data') | Correct. | R |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
int values[69]; values[69]=5; | int values[69]; if(69<69){{}} else values[69]=5; | Bounds check. | C++ |
name: test
age: 89 | name: test
age: 89 | Correct. | YAML |
if ($y = 6) | if ($y == 6) | Use ==. | Perl |
data.forEach(function(x) {{ console.log(x); }}) | data.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
58val = 10 | val58 = 10 | Variable cannot start with digit. | Python |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
object User {{ def main(args: Array[String]) = println("output") }} | object User {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
{{"age":"output" "title":96}} | {{"age":"output", "title":96}} | Add comma. | JSON |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
class Product {{ int foo; }}
obj.foo=5; | class Product {{ public int foo; }}
obj.foo=5; | Make field public. | Java |
local a = 89 | local a = 89 | Correct. | Lua |
switch(count){{ case 60: break; }} | switch(count){{ case 60: break; default: break; }} | Add default case. | Java |
for i=1,71 do print(i) end | for i=1,71 do print(i) end | Correct. | Lua |
values[44] | if values.indices.contains(44) {{ values[44] }} | Check index. | Swift |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
my @arr = (76,99,53); | my @arr = (76,99,53); | Correct. | Perl |
function process(bar:string){{return bar;}} process(99); | function process(bar:string){{return bar;}} process('result'); | Pass correct type. | TypeScript |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
int c = 'test'; | String c = 'test'; | Type mismatch. | Dart |
WHERE email = '32' | WHERE email = 32 | Don't quote integer. | SQL |
'message' + 80 | 'message' + str(80) | Can't add int to string. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
z = 96 | z=96 | No spaces. | Shell |
<person age=67> | <person age="67"> | Quote attribute. | XML |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
val bar = 38; bar = 24 | var bar = 38; bar = 24 | Use var for reassignment. | Scala |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if b = 94 then
print('hello')
end | if b == 94 then
print('hello')
end | Use ==. | Lua |
const user:Person = {{name:'hello'}}; | const user:Person = {{name:'hello', age:95}}; | Add missing property. | TypeScript |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
for (count in arr) | for (count of arr) | for...in iterates keys. | JavaScript |
'66' + 98 | 66 + 98 | Avoid string coercion. | JavaScript |
<ul><li>test<li>test</ul> | <ul><li>test</li><li>test</li></ul> | Close li. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
var x int | var x int | Correct. | Go |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(31); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(31, () => console.log('listening')); | Add callback. | Node.js |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<entry name='value'/> | <entry name="value"/> | Double quotes. | XML |
JOIN profiles ON products.id = profiles.status | JOIN profiles ON products.id = profiles.status | Correct. | SQL |
<input type='text' value='info'> | <input type='text' value='info' name='status'> | Add name attribute. | HTML |
[32, 43, 17 | [32, 43, 17] | Close bracket. | Python |
.Item {{ color: #fff; }} | .Item {{ color: #fff; }} | Correct. | CSS |
var b int = 'world' | var b string = 'world' | Type mismatch. | Go |
echo data hello | echo 'data hello' | Quote to prevent splitting. | Shell |
const a = 72; a = 49; | let a = 72; a = 49; | Cannot reassign const. | JavaScript |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
list[32] | if (length(list) >= 32) list[32] | Check length. | R |
data = output | data = 'output' | Quote strings. | Python |
let data: Int = 'hello' | let data: String = 'hello' | Fix type. | Swift |
values[27] | if (values.indices.contains(27)) values[27] | Check index. | Kotlin |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if [ $val = 1 ]; then | if [ "$val" = 1 ]; then | Quote variable. | Shell |
if (val = 95) | if (val == 95) | Use ==. | R |
val data: Int = 'message' | val data: String = 'message' | Fix type. | Kotlin |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
function process(): void {{ return 35; }} | function process(): number {{ return 35; }} | Return type mismatch. | TypeScript |
$list[50] | if ($list.Count -gt 50) {{ $list[50] }} | Check bounds. | PowerShell |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
String a = 'test'; | String a = "test"; | Double quotes. | Java |
#main {{ color: red; }} | #main {{ color: red; }} | Correct. | CSS |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if (a = 63) | if (a == 63) | Use ==. | Scala |
if (count = 67) {{}} | if (count === 67) {{}} | Use === for equality. | JavaScript |
{{"status":"value",}} | {{"status":"value"}} | Remove trailing comma. | JSON |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
for temp in range(72)
print(temp) | for temp in range(72):
print(temp) | Colon after for. | Python |
if ($x = 11) {{}} | if ($x -eq 11) {{}} | Use -eq. | PowerShell |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(81); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(81, () => console.log('listening')); | Add callback. | Node.js |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
jwt.sign({{id:32}}, 'password'); | jwt.sign({{id:32}}, 'password', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
bar | bar() | Add parentheses. | Kotlin |
const x = 79; x = 9; | let x = 79; x = 9; | Cannot reassign const. | JavaScript |
val = 25 | val=25 | No spaces. | Shell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.