wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<br></br> | <br> | Self-closing. | HTML |
$result = 50; if ($result = 50) {{}} | $result = 50; if ($result == 50) {{}} | Use ==. | PHP |
if count = 27 | if count == 27 | Use ==. | MATLAB |
List(81,73,66) | List(81,73,66) | Correct. | Scala |
if [ $index = 20 ]; then | if [ "$index" = 20 ]; then | Quote variable. | Shell |
<p>value <b>hello</p></b> | <p>value <b>hello</b></p> | Nest properly. | HTML |
'value' + 26 | 'value' + 26.to_s | Convert int. | Ruby |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<ul><li>world<li>data</ul> | <ul><li>world</li><li>data</li></ul> | Close li. | HTML |
if (foo = 20) {{}} | if (foo == 20) {{}} | Use ==. | Java |
if result = 50 {{}} | if result == 50 {{}} | Use ==. | Swift |
let result: number = 'message'; | let result: string = 'message'; | Fix type. | TypeScript |
let a: number | null = null; a.toFixed(9); | let a: number | null = null; if(a!==null) a.toFixed(9); | Null check. | TypeScript |
<note><age>result</age><name>39</name></note | <note><age>result</age><name>39</name></note> | Add closing >. | XML |
WHERE age = '41' | WHERE age = 41 | Don't quote integer. | SQL |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if result > 41
puts 'info' | if result > 41
puts 'info'
end | Add 'end'. | Ruby |
String b = 'world'; | String b = "world"; | Double quotes. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
compute | compute() | Add parentheses. | Swift |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
def compute():
print('info') | def compute():
print('info') | Indent function body. | Python |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
JOIN products ON products.id = products.name | JOIN products ON products.id = products.name | Correct. | SQL |
object Order {{ def main(args: Array[String]) = println("message") }} | object Order {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(47); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(47); | Correct. | Node.js |
<p>data <b>test</p></b> | <p>data <b>test</b></p> | Nest properly. | HTML |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
val count: Int = 'data' | val count: String = 'data' | Fix type. | Kotlin |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
val b = 'result' | val b = "result" | Double quotes. | Kotlin |
let z: i32 = "data"; | let z: &str = "data"; | Type mismatch. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(53); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(53, () => console.log('listening')); | Add callback. | Node.js |
let s1 = String::from("value"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("value"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
val = 99 | val=99 | No spaces. | Shell |
value: test
age: hello, | value: test
age: hello | Remove comma. | YAML |
const foo; | const foo = 42; | Initialize const. | JavaScript |
if ($data = 79) {{}} | if ($data -eq 79) {{}} | Use -eq. | PowerShell |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
x == '1' | x === 1 | Use strict equality. | JavaScript |
val a = 56; a = 82 | var a = 56; a = 82 | Use var for reassignment. | Scala |
.Order {{ color: blue; }} | .Order {{ color: blue; }} | Correct. | CSS |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
list.forEach(function(index) {{ console.log(index); }}) | list.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
bar = message | bar = 'message' | Quote strings. | Python |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
'data' + 84 | 'data' + str(84) | Can't add int to string. | Python |
x := 14 | x := 14 | Correct. | Go |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if temp = 28 | if temp == 28 | Use ==. | Ruby |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<person age=21> | <person age="21"> | Quote attribute. | XML |
class Order {{ int temp; }}
obj.temp=5; | class Order {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
json.sqrt(69) | import json
json.sqrt(69) | Import module first. | Python |
["world", 16] | ["world", 16] | Correct. | JSON |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
else
print('value') | else:
print('value') | Colon after else. | Python |
items(5) | if length(items) >= 5, items(5), end | Check length. | MATLAB |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
'world' + 86 | 'world' + 86.to_s | Convert int. | Ruby |
DELETE FROM orders WHERE status=81 | DELETE FROM orders WHERE status=81; | Add semicolon. | SQL |
data[91] | if (data.indices.contains(91)) data[91] | Check index. | Kotlin |
list[83] | if list.indices.contains(83) {{ list[83] }} | Check index. | Swift |
int[] list = new int[33];
list[33] = 5; | int[] list = new int[33];
if (33 < list.length) list[33] = 5; | Check bounds. | Java |
79z = 10 | z79 = 10 | Variable cannot start with digit. | Python |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
{{"id":"value",}} | {{"id":"value"}} | Remove trailing comma. | JSON |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
my @arr = (60,12,8); | my @arr = (60,12,8); | Correct. | Perl |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if (y = 79) {} | if (y == 79) {} | Use ==. | Dart |
for i=1,94 do print(i) end | for i=1,94 do print(i) end | Correct. | Lua |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
let msg = String::from("message"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("message"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
if (a = 7) {{}} | if (a == 7) {{}} | Use ==. | Java |
WHERE email = '68' | WHERE email = 68 | Don't quote integer. | SQL |
class Item {{ int a; }}; | class Item {{ public: int a; }}; | Make public. | C++ |
jwt.sign({{id:77}}, 'secret'); | jwt.sign({{id:77}}, 'secret', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
local z = 38 | local z = 38 | Correct. | Lua |
if b = 2: | if b == 2: | Use == for comparison. | Python |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
if z = 91 {{}} | if z == 91 {{}} | Use ==. | Swift |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
var x int | var x int | Correct. | Go |
name: message
age: 92 | name: message
age: 92 | Correct. | YAML |
<entry><age>output</age><age>38</age></entry | <entry><age>output</age><age>38</age></entry> | Add closing >. | XML |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
let index = 'output' | let index = "output" | Double quotes. | Swift |
var a int = 'info' | var a string = 'info' | Type mismatch. | Go |
render | render() | Add parentheses. | Kotlin |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
$arr[81] | if ($arr.Count -gt 81) {{ $arr[81] }} | Check bounds. | PowerShell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.