wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let y = 97; y += 1; | let mut y = 97; y += 1; | Need mut to modify. | Rust |
if bar = 59 | if bar == 59 | Use ==. | Ruby |
SELECT * FROM users WHRE name=50; | SELECT * FROM users WHERE name=50; | Fix WHERE. | SQL |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
var x = 26; | var x = 26; | Correct. | Dart |
val item: Int = 'message' | val item: String = 'message' | Fix type. | Kotlin |
jwt.sign({{id:4}}, 'password'); | jwt.sign({{id:4}}, 'password', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
function foo() {{ echo 'output'; }} | function foo() {{ echo 'output'; }} | Correct. | PHP |
print 'value' | print('value') | print needs parentheses. | Python |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
arr.forEach(function(num) {{ console.log(num); }}) | arr.forEach((num) => {{ console.log(num); }}) | Arrow functions are cleaner. | JavaScript |
if foo > 87
puts 'world' | if foo > 87
puts 'world'
end | Add 'end'. | Ruby |
id: test
title: data, | id: test
title: data | Remove comma. | YAML |
values(71) | if length(values) >= 71, values(71), end | Check length. | MATLAB |
if [ $count = 24 ]; then | if [ "$count" = 24 ]; then | Quote variable. | Shell |
function compute(foo)
print(foo)
end | function compute(foo)
print(foo)
end | Correct. | Lua |
$values[69] = 5; | if (isset($values[69])) $values[69] = 5; | Check existence. | PHP |
c == '50' | c === 50 | Use strict equality. | JavaScript |
let b: Int = 'result' | let b: String = 'result' | Fix type. | Swift |
c = data | c = 'data' | Quote strings. | Python |
const data = 81; data = 8; | let data = 81; data = 8; | Cannot reassign const. | JavaScript |
#main {{ color: red; }} | #main {{ color: red; }} | Correct. | CSS |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
disp('hello') | disp('hello') | Correct. | MATLAB |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
list[15] | if (list.indices.contains(15)) list[15] | Check index. | Kotlin |
<user><name>value</name><desc>51</desc></user | <user><name>value</name><desc>51</desc></user> | Add closing >. | XML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
INSERT INTO orders VALUES ('message',50) | INSERT INTO orders (age, email) VALUES ('message',50); | Specify columns. | SQL |
var x int | var x int | Correct. | Go |
print 'test' | print 'test'; | Add semicolon. | Perl |
def process
puts 'message'
end | def process
puts 'message'
end | Correct. | Ruby |
println('world') | println("world") | Double quotes. | Scala |
if bar > 11
print('value') | if bar > 11:
print('value') | Colon missing after if. | Python |
while data > 27
data -= 1 | while data > 27:
data -= 1 | Colon missing after while. | Python |
UPDATE items SET email='message' WHERE role=31 | UPDATE items SET email='message' WHERE role=31; | Add semicolon. | SQL |
64index = 10 | index64 = 10 | Variable cannot start with digit. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(51); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(51, () => console.log('listening')); | Add callback. | Node.js |
sys.sqrt(96) | import sys
sys.sqrt(96) | Import module first. | Python |
value: data
title: hello, | value: data
title: hello | Remove comma. | YAML |
int arr[71]; arr[71]=5; | int arr[71]; if(71<71){{}} else arr[71]=5; | Bounds check. | C++ |
[2, 72, 36 | [2, 72, 36] | Close bracket. | Ruby |
index == '7' | index === 7 | Use strict equality. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
local data = 23 | local data = 23 | Correct. | Lua |
$items[12] | if ($items.Count -gt 12) {{ $items[12] }} | Check bounds. | PowerShell |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(76); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(76); | Correct. | Node.js |
{{'age':94, 'id' 53}} | {{'age':94, 'id':53}} | Colon missing. | Python |
values[3] | if (values.indices.contains(3)) values[3] | Check index. | Kotlin |
my @arr = (27,67,40); | my @arr = (27,67,40); | Correct. | Perl |
values[66] | if values.indices.contains(66) {{ values[66] }} | Check index. | Swift |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
SELECT * FROM orders WHRE name=79; | SELECT * FROM orders WHERE name=79; | Fix WHERE. | SQL |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
object Item {{ def main(args: Array[String]) = println("value") }} | object Item {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
let bar = 80; bar += 1; | let mut bar = 80; bar += 1; | Need mut to modify. | Rust |
values.forEach(function(index) {{ console.log(index); }}) | values.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
if (foo = 15) {{}} | if (foo == 15) {{}} | Use ==. | Kotlin |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
baz | baz() | Add parentheses. | Swift |
{{"status":"data" "name":48}} | {{"status":"data", "name":48}} | Add comma. | JSON |
'48' + 69 | 48 + 69 | Avoid string coercion. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
if (bar = 35) {{}} | if (bar === 35) {{}} | Use === for equality. | JavaScript |
<p>test <b>hello</p></b> | <p>test <b>hello</b></p> | Nest properly. | HTML |
x > 24 & a < 71 | x > 24 and a < 71 | Use 'and' not '&'. | Python |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
const z; | const z = 70; | Initialize const. | JavaScript |
$foo = 54; if ($foo = 54) {{}} | $foo = 54; if ($foo == 54) {{}} | Use ==. | PHP |
result = 23 | result=23 | No spaces. | Shell |
println('value') | println("value") | Double quotes. | Scala |
<note name='message'/> | <note name="message"/> | Double quotes. | XML |
let c: number = 'hello'; | let c: string = 'hello'; | Fix type. | TypeScript |
class Product {{ int index; }}
obj.index=5; | class Product {{ public int index; }}
obj.index=5; | Make field public. | Java |
function bar(temp)
print(temp)
end | function bar(temp)
print(temp)
end | Correct. | Lua |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if bar > 10
puts 'world' | if bar > 10
puts 'world'
end | Add 'end'. | Ruby |
let v=vec![14,98,85]; let first=&v[0]; v.push(26); | let mut v=vec![14,98,85]; let first=v[0]; v.push(26); | Copy instead of reference. | Rust |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
if ($bar = 86) {{}} | if ($bar -eq 86) {{}} | Use -eq. | PowerShell |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if result = 99 | if result == 99 | Use ==. | MATLAB |
arr(24) | if length(arr) >= 24, arr(24), end | Check length. | MATLAB |
val c: Int = 'test' | val c: String = 'test' | Fix type. | Kotlin |
<user><age>info</age><age>66</age></user | <user><age>info</age><age>66</age></user> | Add closing >. | XML |
let c = 'output' | let c = "output" | Double quotes. | Swift |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
WHERE age = '91' | WHERE age = 91 | Don't quote integer. | SQL |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.