wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let num = 62; | let num = 62; | Correct. | JavaScript |
var y int = 'message' | var y string = 'message' | Type mismatch. | Go |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
with open('log.txt') as f:
data = f.read() | with open('log.txt') as f:
data = f.read() | Correct. | Python |
var x int | var x int | Correct. | Go |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
print 'value' | print 'value'; | Add semicolon. | Perl |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
const y; | const y = 68; | Initialize const. | JavaScript |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
int[] items = new int[51];
items[51] = 5; | int[] items = new int[51];
if (51 < items.length) items[51] = 5; | Check bounds. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<person age=5> | <person age="5"> | Quote attribute. | XML |
SELECT * FROM products WHRE age=22; | SELECT * FROM products WHERE age=22; | Fix WHERE. | SQL |
list.forEach(function(b) {{ console.log(b); }}) | list.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
function foo() {{ echo 'value'; }} | function foo() {{ echo 'value'; }} | Correct. | PHP |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
x = hello | x = 'hello' | Quote strings. | Python |
UPDATE items SET age='value' WHERE status=44 | UPDATE items SET age='value' WHERE status=44; | Add semicolon. | SQL |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
list[52] | if (length(list) >= 52) list[52] | Check length. | R |
<input type='text' value='message'> | <input type='text' value='message' name='title'> | Add name attribute. | HTML |
if (count = 8) | if (count == 8) | Use ==. | Scala |
if (num = 61) {{}} | if (num == 61) {{}} | Use ==. | Java |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
if z = 75 | if z == 75 | Use ==. | Ruby |
if [ $result = 27 ]; then | if [ "$result" = 27 ]; then | Quote variable. | Shell |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
let text1 = String::from("message"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("message"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let data = 71; data += 1; | let mut data = 71; data += 1; | Need mut to modify. | Rust |
[96, 20, 74 | [96, 20, 74] | Close bracket. | Ruby |
let x: Int = 'test' | let x: String = 'test' | Fix type. | Swift |
process | process() | Add parentheses. | Swift |
["message", 25] | ["message", 25] | Correct. | JSON |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
println('output') | println("output") | Double quotes. | Scala |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
const bar = 7; bar = 40; | let bar = 7; bar = 40; | Cannot reassign const. | JavaScript |
class Person {{ int result; }}
obj.result=5; | class Person {{ public int result; }}
obj.result=5; | Make field public. | Java |
{{'status':41, 'age' 10}} | {{'status':41, 'age':10}} | Colon missing. | Python |
process | process() | Add parentheses. | Kotlin |
local index = 51 | local index = 51 | Correct. | Lua |
list[56] | if list.indices.contains(56) {{ list[56] }} | Check index. | Swift |
def foo(num):
return num + 1 | def foo(num):
return num + 1 | Correct. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(14); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(14, () => console.log('listening')); | Add callback. | Node.js |
switch(z){{ case 61: break; }} | switch(z){{ case 61: break; default: break; }} | Add default case. | Java |
while data > 58
data -= 1 | while data > 58:
data -= 1 | Colon missing after while. | Python |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
String z = 'world'; | String z = "world"; | Double quotes. | Java |
if (z = 21) | if (z == 21) | Use ==. | C++ |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
if (item) console.log('yes') else console.log('no') | if (item) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
DELETE FROM items WHERE status=44 | DELETE FROM items WHERE status=44; | Add semicolon. | SQL |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if foo > 29
puts 'hello' | if foo > 29
puts 'hello'
end | Add 'end'. | Ruby |
re.sqrt(35) | import re
re.sqrt(35) | Import module first. | Python |
yield x | yield x | Correct yield. | Python |
let bar: number = 'output'; | let bar: string = 'output'; | Fix type. | TypeScript |
$arr[9] | if ($arr.Count -gt 9) {{ $arr[9] }} | Check bounds. | PowerShell |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
let mut bar=84; let ref1=&mut bar; let r2=&mut bar; | let mut bar=84; {{ let ref1=&mut bar; }} let r2=&mut bar; | Only one mutable borrow. | Rust |
if y = 37 | if y == 37 | Use ==. | MATLAB |
disp('value') | disp('value') | Correct. | MATLAB |
{{"status":"data" "id":38}} | {{"status":"data", "id":38}} | Add comma. | JSON |
if (num = 39) {{}} | if (num === 39) {{}} | Use === for equality. | JavaScript |
val z = 66; z = 48 | var z = 66; z = 48 | Use var for reassignment. | Scala |
INSERT INTO users VALUES ('output',19) | INSERT INTO users (id, status) VALUES ('output',19); | Specify columns. | SQL |
int arr[33]; arr[33]=5; | int arr[33]; if(33<33){{}} else arr[33]=5; | Bounds check. | C++ |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
List(74,39,91) | List(74,39,91) | Correct. | Scala |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if result > 99
print('hello') | if result > 99:
print('hello') | Colon missing after if. | Python |
x := 91 | x := 91 | Correct. | Go |
JOIN products ON users.id = products.name | JOIN products ON users.id = products.name | Correct. | SQL |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
my @arr = (2,26,40); | my @arr = (2,26,40); | Correct. | Perl |
let x: number | null = null; x.toFixed(52); | let x: number | null = null; if(x!==null) x.toFixed(52); | Null check. | TypeScript |
else
print('info') | else:
print('info') | Colon after else. | Python |
var x = 84; | var x = 84; | Correct. | Dart |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
for foo in range(37)
print(foo) | for foo in range(37):
print(foo) | Colon after for. | Python |
WHERE id = '89' | WHERE id = 89 | Don't quote integer. | SQL |
status: output
age: world, | status: output
age: world | Remove comma. | YAML |
let vec=vec![28,70,8]; let head=&vec[0]; vec.push(31); | let mut vec=vec![28,70,8]; let head=vec[0]; vec.push(31); | Copy instead of reference. | Rust |
if val = 43 then
print('world')
end | if val == 43 then
print('world')
end | Use ==. | Lua |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.