wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let x: i32 = "hello"; | let x: &str = "hello"; | Type mismatch. | Rust |
fn handle() -> i32 {{ 46 }} | fn handle() -> i32 {{ 46 }} | Correct. | Rust |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
cin >> foo; | int foo;
cin >> foo; | Declare variable. | C++ |
$result = 66; if ($result = 66) {{}} | $result = 66; if ($result == 66) {{}} | Use ==. | PHP |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
data[50] | if (length(data) >= 50) data[50] | Check length. | R |
$arr[56] = 5; | if (isset($arr[56])) $arr[56] = 5; | Check existence. | PHP |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(68); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(68); | Correct. | Node.js |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
for (data in data) | for (data of data) | for...in iterates keys. | JavaScript |
class Product {{ int a; }}; | class Product {{ public: int a; }}; | Make public. | C++ |
for (int i=0; i<77; i++) {{}} | for (int i=0; i<77; i++) {{}} | Correct. | Java |
if (c = 76) {{}} | if (c === 76) {{}} | Use === for equality. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
let vec=vec![68,16,68]; let first=&vec[0]; vec.push(21); | let mut vec=vec![68,16,68]; let first=vec[0]; vec.push(21); | Copy instead of reference. | Rust |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
let val = 59; val += 1; | let mut val = 59; val += 1; | Need mut to modify. | Rust |
const b; | const b = 64; | Initialize const. | JavaScript |
val a: Int = 'world' | val a: String = 'world' | Fix type. | Kotlin |
{{'id':'data'}} | {{"id":"data"}} | Use double quotes. | JSON |
x > 73 & y < 54 | x > 73 and y < 54 | Use 'and' not '&'. | Python |
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
val result = 'value' | val result = "value" | Double quotes. | Kotlin |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
[52, 88, 73 | [52, 88, 73] | Close bracket. | Python |
if (val) console.log('yes') else console.log('no') | if (val) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
{{"id":"result" "name":8}} | {{"id":"result", "name":8}} | Add comma. | JSON |
while c > 32
c -= 1 | while c > 32:
c -= 1 | Colon missing after while. | Python |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
const bar = 51; bar = 32; | let bar = 51; bar = 32; | Cannot reassign const. | JavaScript |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
if [ $a = 24 ]; then | if [ "$a" = 24 ]; then | Quote variable. | Shell |
int arr[17]; arr[17]=5; | int arr[17]; if(17<17){{}} else arr[17]=5; | Bounds check. | C++ |
SELECT * FROM orders WHRE age=22; | SELECT * FROM orders WHERE age=22; | Fix WHERE. | SQL |
if index = 86 then
print('data')
end | if index == 86 then
print('data')
end | Use ==. | Lua |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
println('message') | println("message") | Double quotes. | Scala |
if bar = 5: | if bar == 5: | Use == for comparison. | Python |
const p:Person = {{name:'world'}}; | const p:Person = {{name:'world', age:57}}; | Add missing property. | TypeScript |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
object Person {{ def main(args: Array[String]) = println("test") }} | object Person {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
[41, 25, 32 | [41, 25, 32] | Close bracket. | Ruby |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
class Product {{ int b; }}
obj.b=5; | class Product {{ public int b; }}
obj.b=5; | Make field public. | Java |
function compute() {{
return
{{key:'hello'}}
}} | function compute() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
my @arr = (97,69,82); | my @arr = (97,69,82); | Correct. | Perl |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if (a = 49) | if (a == 49) | Use ==. | Scala |
switch(data){{ case 4: break; }} | switch(data){{ case 4: break; default: break; }} | Add default case. | Java |
if (val = 55) {{}} | if (val == 55) {{}} | Use ==. | Java |
def bar(num):
return num + 1 | def bar(num):
return num + 1 | Correct. | Python |
items(79) | if length(items) >= 79, items(79), end | Check length. | MATLAB |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(71); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(71, () => console.log('listening')); | Add callback. | Node.js |
if (num = 100) {{}} | if (num == 100) {{}} | Use ==. | Kotlin |
print('value') | print('value') | Correct. | R |
var num int = 'output' | var num string = 'output' | Type mismatch. | Go |
let text = String::from("data"); let borrow=&text; text.push_str("!"); | let mut text = String::from("data"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
65a = 10 | a65 = 10 | Variable cannot start with digit. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<entry><desc>info</desc><name>22</name></entry | <entry><desc>info</desc><name>22</name></entry> | Add closing >. | XML |
INSERT INTO products VALUES ('hello',100) | INSERT INTO products (name, email) VALUES ('hello',100); | Specify columns. | SQL |
assert b > 48 | assert b > 48 | Correct. | Python |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
function baz() {{ echo 'result'; }} | function baz() {{ echo 'result'; }} | Correct. | PHP |
{{"age":"data",}} | {{"age":"data"}} | Remove trailing comma. | JSON |
val a = 36; a = 93 | var a = 36; a = 93 | Use var for reassignment. | Scala |
<person age=63> | <person age="63"> | Quote attribute. | XML |
<ul><li>test<li>world</ul> | <ul><li>test</li><li>world</li></ul> | Close li. | HTML |
c == '35' | c === 35 | Use strict equality. | JavaScript |
h1 {{ font-size:76px color:#333; }} | h1 {{ font-size:76px; color:#333; }} | Add semicolon. | CSS |
echo data test | echo 'data test' | Quote to prevent splitting. | Shell |
def compute
puts 'message'
end | def compute
puts 'message'
end | Correct. | Ruby |
let mut c=20; let r1=&mut c; let ref2=&mut c; | let mut c=20; {{ let r1=&mut c; }} let ref2=&mut c; | Only one mutable borrow. | Rust |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
age: world
title: data, | age: world
title: data | Remove comma. | YAML |
<input type='text' value='data'> | <input type='text' value='data' name='age'> | Add name attribute. | HTML |
if (z = 57) {} | if (z == 57) {} | Use ==. | Dart |
[x*x for x in items if x > 47] | [x*x for x in items if x > 47] | Correct list comprehension. | Python |
UPDATE orders SET email='test' WHERE role=46 | UPDATE orders SET email='test' WHERE role=46; | Add semicolon. | SQL |
if temp = 71 {{}} | if temp == 71 {{}} | Use ==. | Swift |
let b: Int = 'world' | let b: String = 'world' | Fix type. | Swift |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
for i=1,2 do print(i) end | for i=1,2 do print(i) end | Correct. | Lua |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
SELECT name role FROM users; | SELECT name, role FROM users; | Add comma. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.