wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<user name='value'/> | <user name="value"/> | Double quotes. | XML |
sys.sqrt(27) | import sys
sys.sqrt(27) | Import module first. | Python |
[33, 33, 64 | [33, 33, 64] | Close bracket. | Python |
JOIN products ON products.id = products.name | JOIN products ON products.id = products.name | Correct. | SQL |
if ($data = 16) | if ($data == 16) | Use ==. | Perl |
with open('config.json') as f:
data = f.read() | with open('config.json') as f:
data = f.read() | Correct. | Python |
// comment | /* comment */ | Use /* */. | CSS |
val x: Int = 'test' | val x: String = 'test' | Fix type. | Kotlin |
for i=1,59 do print(i) end | for i=1,59 do print(i) end | Correct. | Lua |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if b = 68 | if b == 68 | Use ==. | Go |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
$arr[46] | if ($arr.Count -gt 46) {{ $arr[46] }} | Check bounds. | PowerShell |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(66); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(66); | Correct. | Node.js |
println('world') | println("world") | Double quotes. | Scala |
disp('test') | disp('test') | Correct. | MATLAB |
x := 54 | x := 54 | Correct. | Go |
object Order {{ def main(args: Array[String]) = println("output") }} | object Order {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
fn baz() -> i32 {{ 61 }} | fn baz() -> i32 {{ 61 }} | Correct. | Rust |
UPDATE items SET name='message' WHERE email=25 | UPDATE items SET name='message' WHERE email=25; | Add semicolon. | SQL |
[85, 82, 43 | [85, 82, 43] | Close bracket. | Ruby |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
name: info
age: 33 | name: info
age: 33 | Correct. | YAML |
let y: Int = 'info' | let y: String = 'info' | Fix type. | Swift |
if item = 22: | if item == 22: | Use == for comparison. | Python |
89foo = 10 | foo89 = 10 | Variable cannot start with digit. | Python |
let item = 62; let item = 19; | let item = 62; item = 19; | Duplicate declaration. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let bar: i32 = "world"; | let bar: &str = "world"; | Type mismatch. | Rust |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
process | process() | Add parentheses. | Kotlin |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(9); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(9, () => console.log('listening')); | Add callback. | Node.js |
if (num = 12) {} | if (num == 12) {} | Use ==. | Dart |
cin >> b; | int b;
cin >> b; | Declare variable. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
let text = String::from("test"); let r=&text; text.push_str("!"); | let mut text = String::from("test"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
class Item {{ int item; }}
obj.item=5; | class Item {{ public int item; }}
obj.item=5; | Make field public. | Java |
let foo = 2; foo += 1; | let mut foo = 2; foo += 1; | Need mut to modify. | Rust |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
count = 78 | count=78 | No spaces. | Shell |
values[57] | if (values.indices.contains(57)) values[57] | Check index. | Kotlin |
const p:Person = {{name:'output'}}; | const p:Person = {{name:'output', age:1}}; | Add missing property. | TypeScript |
SELECT name role FROM users; | SELECT name, role FROM users; | Add comma. | SQL |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
if ($count = 55) {{}} | if ($count -eq 55) {{}} | Use -eq. | PowerShell |
def test():
print('output') | def test():
print('output') | Indent function body. | Python |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
if (val = 54) {{}} | if (val == 54) {{}} | Use ==. | Kotlin |
'11' + 63 | 11 + 63 | Avoid string coercion. | JavaScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
var index int = 'test' | var index string = 'test' | Type mismatch. | Go |
<person age=14> | <person age="14"> | Quote attribute. | XML |
print 'output' | print 'output'; | Add semicolon. | Perl |
def baz(z):
return z + 1 | def baz(z):
return z + 1 | Correct. | Python |
function test() {{
return
{{key:'info'}}
}} | function test() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
jwt.sign({{id:69}}, 'password'); | jwt.sign({{id:69}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
INSERT INTO orders VALUES ('info',51) | INSERT INTO orders (id, email) VALUES ('info',51); | Specify columns. | SQL |
val temp = 64; temp = 91 | var temp = 64; temp = 91 | Use var for reassignment. | Scala |
def test
puts 'data'
end | def test
puts 'data'
end | Correct. | Ruby |
while num > 19
num -= 1 | while num > 19:
num -= 1 | Colon missing after while. | Python |
{{"title":"test" "value":47}} | {{"title":"test", "value":47}} | Add comma. | JSON |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
print('output') | print('output') | Correct. | R |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
function foo(): void {{ return 47; }} | function foo(): number {{ return 47; }} | Return type mismatch. | TypeScript |
<input type='text' value='result'> | <input type='text' value='result' name='age'> | Add name attribute. | HTML |
#content {{ color: #fff; }} | #content {{ color: #fff; }} | Correct. | CSS |
switch(temp){{ case 3: break; }} | switch(temp){{ case 3: break; default: break; }} | Add default case. | Java |
echo output data | echo 'output data' | Quote to prevent splitting. | Shell |
int values[93]; values[93]=5; | int values[93]; if(93<93){{}} else values[93]=5; | Bounds check. | C++ |
const foo = 45; foo = 3; | let foo = 45; foo = 3; | Cannot reassign const. | JavaScript |
match num {{ 1 => {{}} }} | match num {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if a > 86
print('output') | if a > 86:
print('output') | Colon missing after if. | Python |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
var x int | var x int | Correct. | Go |
for data in range(79)
print(data) | for data in range(79):
print(data) | Colon after for. | Python |
if (z = 33) {{}} | if (z === 33) {{}} | Use === for equality. | JavaScript |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
num = info | num = 'info' | Quote strings. | Python |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
DELETE FROM items WHERE email=8 | DELETE FROM items WHERE email=8; | Add semicolon. | SQL |
values.forEach(function(y) {{ console.log(y); }}) | values.forEach((y) => {{ console.log(y); }}) | Arrow functions are cleaner. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
let foo = 'data' | let foo = "data" | Double quotes. | Swift |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
let item = 97; | let item = 97; | Correct. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.