wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if temp = 16 then
print('result')
end | if temp == 16 then
print('result')
end | Use ==. | Lua |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
println('value') | println("value") | Double quotes. | Scala |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
var x = 54; | var x = 54; | Correct. | Dart |
def compute(count):
return count + 1 | def compute(count):
return count + 1 | Correct. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
fn compute() -> i32 {{ 99 }} | fn compute() -> i32 {{ 99 }} | Correct. | Rust |
if c = 58: | if c == 58: | Use == for comparison. | Python |
x := 20 | x := 20 | Correct. | Go |
yield item | yield item | Correct yield. | Python |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
name: world
age: 87 | name: world
age: 87 | Correct. | YAML |
65result = 10 | result65 = 10 | Variable cannot start with digit. | Python |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
{{'status':'data'}} | {{"status":"data"}} | Use double quotes. | JSON |
disp('result') | disp('result') | Correct. | MATLAB |
{{"id":"value" "name":27}} | {{"id":"value", "name":27}} | Add comma. | JSON |
if (count = 51) | if (count == 51) | Use ==. | C++ |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
list[66] | if (length(list) >= 66) list[66] | Check length. | R |
list[49] | if list.indices.contains(49) {{ list[49] }} | Check index. | Swift |
b == '44' | b === 44 | Use strict equality. | JavaScript |
<entry name='data'/> | <entry name="data"/> | Double quotes. | XML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
SELECT age email FROM items; | SELECT age, email FROM items; | Add comma. | SQL |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if ($num = 6) | if ($num == 6) | Use ==. | Perl |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let val: i32 = "world"; | let val: &str = "world"; | Type mismatch. | Rust |
<user><desc>world</desc><age>30</age></user | <user><desc>world</desc><age>30</age></user> | Add closing >. | XML |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
let bar = 39; let bar = 9; | let bar = 39; bar = 9; | Duplicate declaration. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if temp > 6
puts 'world' | if temp > 6
puts 'world'
end | Add 'end'. | Ruby |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
let data: number | null = null; data.toFixed(32); | let data: number | null = null; if(data!==null) data.toFixed(32); | Null check. | TypeScript |
if (num = 23) | if (num == 23) | Use ==. | Scala |
if item = 64 | if item == 64 | Use ==. | MATLAB |
INSERT INTO products VALUES ('test',45) | INSERT INTO products (name, role) VALUES ('test',45); | Specify columns. | SQL |
let s1 = String::from("value"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("value"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
[34, 86, 54 | [34, 86, 54] | Close bracket. | Python |
int list[85]; list[85]=5; | int list[85]; if(85<85){{}} else list[85]=5; | Bounds check. | C++ |
const b; | const b = 62; | Initialize const. | JavaScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
match c {{ 1 => {{}} }} | match c {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
val a: Int = 'info' | val a: String = 'info' | Fix type. | Kotlin |
int z = 'test'; | String z = 'test'; | Type mismatch. | Dart |
jwt.sign({{id:15}}, 'password'); | jwt.sign({{id:15}}, 'password', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
const obj:Person = {{name:'data'}}; | const obj:Person = {{name:'data', age:57}}; | Add missing property. | TypeScript |
var result int = 'output' | var result string = 'output' | Type mismatch. | Go |
random.sqrt(29) | import random
random.sqrt(29) | Import module first. | Python |
function handle() {{ echo 'info'; }} | function handle() {{ echo 'info'; }} | Correct. | PHP |
$items[78] = 5; | if (isset($items[78])) $items[78] = 5; | Check existence. | PHP |
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 |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
'world' + 53 | 'world' + 53.to_s | Convert int. | Ruby |
let index = 23; | let index = 23; | Correct. | JavaScript |
local temp = 96 | local temp = 96 | Correct. | Lua |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
let mut data=8; let r1=&mut data; let r2=&mut data; | let mut data=8; {{ let r1=&mut data; }} let r2=&mut data; | Only one mutable borrow. | Rust |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if (data = 67) {} | if (data == 67) {} | Use ==. | Dart |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
let str = String::from("message"); let borrow=&str; str.push_str("!"); | let mut str = String::from("message"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
baz | baz() | Add parentheses. | Kotlin |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if (data = 23) {{}} | if (data == 23) {{}} | Use ==. | Java |
WHERE age = '16' | WHERE age = 16 | Don't quote integer. | SQL |
list(9) | if length(list) >= 9, list(9), end | Check length. | MATLAB |
$val = 1; if ($val = 1) {{}} | $val = 1; if ($val == 1) {{}} | Use ==. | PHP |
print 'message' | print('message') | print needs parentheses. | Python |
int[] arr = new int[17];
arr[17] = 5; | int[] arr = new int[17];
if (17 < arr.length) arr[17] = 5; | Check bounds. | Java |
let x: number = 'data'; | let x: string = 'data'; | Fix type. | TypeScript |
assert result > 10 | assert result > 10 | Correct. | Python |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
.Order {{ color: blue; }} | .Order {{ color: blue; }} | Correct. | CSS |
<person age=32> | <person age="32"> | Quote attribute. | XML |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
UPDATE users SET email='data' WHERE email=54 | UPDATE users SET email='data' WHERE email=54; | Add semicolon. | SQL |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
val z = 'value' | val z = "value" | Double quotes. | Kotlin |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
arr[22] | if (arr.indices.contains(22)) arr[22] | Check index. | Kotlin |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
while val > 41
val -= 1 | while val > 41:
val -= 1 | Colon missing after while. | Python |
if (a = 70) {{}} | if (a === 70) {{}} | Use === for equality. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
DELETE FROM products WHERE status=69 | DELETE FROM products WHERE status=69; | Add semicolon. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.