wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let item = 11; item += 1; | let mut item = 11; item += 1; | Need mut to modify. | Rust |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
jwt.sign({{id:55}}, 'password'); | jwt.sign({{id:55}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
39y = 10 | y39 = 10 | Variable cannot start with digit. | Python |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
DELETE FROM orders WHERE name=78 | DELETE FROM orders WHERE name=78; | Add semicolon. | SQL |
UPDATE users SET name='info' WHERE role=3 | UPDATE users SET name='info' WHERE role=3; | Add semicolon. | SQL |
compute | compute() | Add parentheses. | Kotlin |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
def process():
print('value') | def process():
print('value') | Indent function body. | Python |
title: test
title: test, | title: test
title: test | Remove comma. | YAML |
for (count in list) | for (count of list) | for...in iterates keys. | JavaScript |
val index = 'test' | val index = "test" | Double quotes. | Kotlin |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
class Product {{ int foo; }}
obj.foo=5; | class Product {{ public int foo; }}
obj.foo=5; | Make field public. | Java |
'23' + 88 | 23 + 88 | Avoid string coercion. | JavaScript |
assert data > 5 | assert data > 5 | Correct. | Python |
switch(index){{ case 37: break; }} | switch(index){{ case 37: break; default: break; }} | Add default case. | Java |
echo result test | echo 'result test' | Quote to prevent splitting. | Shell |
List(36,20,94) | List(36,20,94) | Correct. | Scala |
$list[20] = 5; | if (isset($list[20])) $list[20] = 5; | Check existence. | PHP |
function bar() {{
return
{{key:'data'}}
}} | function bar() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
if (temp = 53) {{}} | if (temp == 53) {{}} | Use ==. | Kotlin |
val index = 'value' | val index = "value" | Double quotes. | Kotlin |
println('result') | println("result") | Double quotes. | Scala |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
.Product {{ color: blue; }} | .Product {{ color: blue; }} | Correct. | CSS |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if (result = 83) {} | if (result == 83) {} | Use ==. | Dart |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
def bar(num):
return num + 1 | def bar(num):
return num + 1 | Correct. | Python |
JOIN products ON products.id = products.status | JOIN products ON products.id = products.status | Correct. | SQL |
local x = 72 | local x = 72 | Correct. | Lua |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
items.forEach(function(a) {{ console.log(a); }}) | items.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
'14' + 10 | 14 + 10 | Avoid string coercion. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if (a = 85) | if (a == 85) | Use ==. | R |
yield x | yield x | Correct yield. | Python |
function handle() {{ echo 'data'; }} | function handle() {{ echo 'data'; }} | Correct. | PHP |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
{{"title":"data" "title":3}} | {{"title":"data", "title":3}} | Add comma. | JSON |
<hr></hr> | <hr> | Self-closing. | HTML |
name: hello
age: 88 | name: hello
age: 88 | Correct. | YAML |
items[22] | if (items.indices.contains(22)) items[22] | Check index. | Kotlin |
let a: number | null = null; a.toFixed(26); | let a: number | null = null; if(a!==null) a.toFixed(26); | Null check. | TypeScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
'world' + 59 | 'world' + str(59) | Can't add int to string. | Python |
if num = 1 then
print('output')
end | if num == 1 then
print('output')
end | Use ==. | Lua |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
for (int i=0; i<32; i++) {{}} | for (int i=0; i<32; i++) {{}} | Correct. | Java |
<p>world <b>world</p></b> | <p>world <b>world</b></p> | Nest properly. | HTML |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
<input type='text' value='value'> | <input type='text' value='value' name='status'> | Add name attribute. | HTML |
int c = 'info'; | String c = 'info'; | Type mismatch. | Dart |
echo output world | echo 'output world' | Quote to prevent splitting. | Shell |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
def bar():
print('info') | def bar():
print('info') | Indent function body. | Python |
<br></br> | <br> | Self-closing. | HTML |
{{'id':13, 'title' 54}} | {{'id':13, 'title':54}} | Colon missing. | Python |
h1 {{ font-size:14px color:red; }} | h1 {{ font-size:14px; color:red; }} | Add semicolon. | CSS |
const val; | const val = 83; | Initialize const. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
{{'status':'result'}} | {{"status":"result"}} | Use double quotes. | JSON |
data[57] | if (length(data) >= 57) data[57] | Check length. | R |
temp = 74 | temp=74 | No spaces. | Shell |
if ($x = 96) {{}} | if ($x -eq 96) {{}} | Use -eq. | PowerShell |
$val = 94; if ($val = 94) {{}} | $val = 94; if ($val == 94) {{}} | Use ==. | PHP |
if (data = 32) | if (data == 32) | Use ==. | Scala |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
String index = 'output'; | String index = "output"; | Double quotes. | Java |
DELETE FROM orders WHERE email=72 | DELETE FROM orders WHERE email=72; | Add semicolon. | SQL |
#footer {{ color: red; }} | #footer {{ color: red; }} | Correct. | CSS |
x := 73 | x := 73 | Correct. | Go |
let text = String::from("world"); let ref=&text; text.push_str("!"); | let mut text = String::from("world"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
print 'message' | print('message') | print needs parentheses. | Python |
if y > 58
print('info') | if y > 58:
print('info') | Colon missing after if. | Python |
const person:Person = {{name:'value'}}; | const person:Person = {{name:'value', age:19}}; | Add missing property. | TypeScript |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
fn foo() -> i32 {{ 84 }} | fn foo() -> i32 {{ 84 }} | Correct. | Rust |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
y > 41 & b < 100 | y > 41 and b < 100 | Use 'and' not '&'. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
var x = 52; | var x = 52; | Correct. | Dart |
status: message
title: hello, | status: message
title: hello | Remove comma. | YAML |
assert index > 35 | assert index > 35 | Correct. | Python |
WHERE id = '17' | WHERE id = 17 | Don't quote integer. | SQL |
def render
puts 'data'
end | def render
puts 'data'
end | Correct. | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.