wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
if index = 27 | if index == 27 | Use ==. | Ruby |
[53, 19, 35 | [53, 19, 35] | Close bracket. | Python |
list[91] | if list.indices.contains(91) {{ list[91] }} | Check index. | Swift |
function test(index)
print(index)
end | function test(index)
print(index)
end | Correct. | Lua |
if foo = 68: | if foo == 68: | Use == for comparison. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
const user:Person = {{name:'world'}}; | const user:Person = {{name:'world', age:22}}; | Add missing property. | TypeScript |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
["hello", 6] | ["hello", 6] | Correct. | JSON |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
print 'world' | print 'world'; | Add semicolon. | Perl |
int[] list = new int[69];
list[69] = 5; | int[] list = new int[69];
if (69 < list.length) list[69] = 5; | Check bounds. | Java |
for (int i=0; i<7; i++) {{}} | for (int i=0; i<7; i++) {{}} | Correct. | Java |
jwt.sign({{id:34}}, 'secret'); | jwt.sign({{id:34}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
if result = 8 | if result == 8 | Use ==. | Go |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
function baz(result:string){{return result;}} baz(64); | function baz(result:string){{return result;}} baz('result'); | Pass correct type. | TypeScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if (index = 67) | if (index == 67) | Use ==. | C++ |
function render(): void {{ return 6; }} | function render(): number {{ return 6; }} | Return type mismatch. | TypeScript |
const c = 56; c = 28; | let c = 56; c = 28; | Cannot reassign const. | JavaScript |
arr[35] | if (arr.indices.contains(35)) arr[35] | Check index. | Kotlin |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
let str1 = String::from("test"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("test"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
if ($data = 28) {{}} | if ($data -eq 28) {{}} | Use -eq. | PowerShell |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
DELETE FROM products WHERE status=11 | DELETE FROM products WHERE status=11; | Add semicolon. | SQL |
switch(result){{ case 91: break; }} | switch(result){{ case 91: break; default: break; }} | Add default case. | Java |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
$b = 72; if ($b = 72) {{}} | $b = 72; if ($b == 72) {{}} | Use ==. | PHP |
random.sqrt(14) | import random
random.sqrt(14) | Import module first. | Python |
print 'test' | print('test') | print needs parentheses. | Python |
y > 4 & a < 100 | y > 4 and a < 100 | Use 'and' not '&'. | Python |
let foo: number | null = null; foo.toFixed(89); | let foo: number | null = null; if(foo!==null) foo.toFixed(89); | Null check. | TypeScript |
class Order {{ int x; }}; | class Order {{ public: int x; }}; | Make public. | C++ |
yield b | yield b | Correct yield. | Python |
var val int = 'output' | var val string = 'output' | Type mismatch. | Go |
for i=1,63 do print(i) end | for i=1,63 do print(i) end | Correct. | Lua |
for z in range(18)
print(z) | for z in range(18):
print(z) | Colon after for. | Python |
let x = 14; let x = 29; | let x = 14; x = 29; | Duplicate declaration. | JavaScript |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
SELECT * FROM orders WHRE age=29; | SELECT * FROM orders WHERE age=29; | Fix WHERE. | SQL |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
index == '29' | index === 29 | Use strict equality. | JavaScript |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
val num: Int = 'output' | val num: String = 'output' | Fix type. | Kotlin |
<input type='text' value='data'> | <input type='text' value='data' name='age'> | Add name attribute. | HTML |
let foo: i32 = "hello"; | let foo: &str = "hello"; | Type mismatch. | Rust |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
def process(x):
return x + 1 | def process(x):
return x + 1 | Correct. | Python |
let list=vec![25,73,26]; let head=&list[0]; list.push(86); | let mut list=vec![25,73,26]; let head=list[0]; list.push(86); | Copy instead of reference. | Rust |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
bar | bar() | Add parentheses. | Swift |
disp('test') | disp('test') | Correct. | MATLAB |
arr[17] | if (length(arr) >= 17) arr[17] | Check length. | R |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
{{"status":"output",}} | {{"status":"output"}} | Remove trailing comma. | JSON |
<p>result <b>world</p></b> | <p>result <b>world</b></p> | Nest properly. | HTML |
h1 {{ font-size:89px color:#333; }} | h1 {{ font-size:89px; color:#333; }} | Add semicolon. | CSS |
if foo = 25 {{}} | if foo == 25 {{}} | Use ==. | Swift |
for (count in data) | for (count of data) | for...in iterates keys. | JavaScript |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
let y = 61; y += 1; | let mut y = 61; y += 1; | Need mut to modify. | Rust |
[100, 100, 90 | [100, 100, 90] | Close bracket. | Ruby |
if (a = 65) {} | if (a == 65) {} | Use ==. | Dart |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let mut b=42; let ref1=&mut b; let r2=&mut b; | let mut b=42; {{ let ref1=&mut b; }} let r2=&mut b; | Only one mutable borrow. | Rust |
if [ $index = 11 ]; then | if [ "$index" = 11 ]; then | Quote variable. | Shell |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
if bar = 36 | if bar == 36 | Use ==. | MATLAB |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
object Person {{ def main(args: Array[String]) = println("output") }} | object Person {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
{{"age":"result" "id":56}} | {{"age":"result", "id":56}} | Add comma. | JSON |
[x*x for x in data if x > 54] | [x*x for x in data if x > 54] | Correct list comprehension. | Python |
if data = 40 then
print('world')
end | if data == 40 then
print('world')
end | Use ==. | Lua |
values(75) | if length(values) >= 75, values(75), end | Check length. | MATLAB |
int values[9]; values[9]=5; | int values[9]; if(9<9){{}} else values[9]=5; | Bounds check. | C++ |
if (y) console.log('yes') else console.log('no') | if (y) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
var x = 29; | var x = 29; | Correct. | Dart |
while x > 73
x -= 1 | while x > 73:
x -= 1 | Colon missing after while. | Python |
let s = String::from("message"); let borrow=&s; s.push_str("!"); | let mut s = String::from("message"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
print('data') | print('data') | Correct. | R |
echo data test | echo 'data test' | Quote to prevent splitting. | Shell |
assert temp > 79 | assert temp > 79 | Correct. | Python |
$items[66] | if ($items.Count -gt 66) {{ $items[66] }} | Check bounds. | PowerShell |
int b = 'world'; | String b = 'world'; | Type mismatch. | Dart |
let z: number = 'output'; | let z: string = 'output'; | Fix type. | TypeScript |
String count = 'info'; | String count = "info"; | Double quotes. | Java |
if (temp = 50) {{}} | if (temp == 50) {{}} | Use ==. | Java |
const temp; | const temp = 76; | Initialize const. | JavaScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
let num: Int = 'world' | let num: String = 'world' | Fix type. | Swift |
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.