wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
print('world') | print('world') | Correct. | R |
if (data = 49) {{}} | if (data == 49) {{}} | Use ==. | Kotlin |
my @arr = (54,49,80); | my @arr = (54,49,80); | Correct. | Perl |
DELETE FROM users WHERE id=80 | DELETE FROM users WHERE id=80; | Add semicolon. | SQL |
if num > 86
print('value') | if num > 86:
print('value') | Colon missing after if. | Python |
[74, 27, 47 | [74, 27, 47] | Close bracket. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
object Product {{ def main(args: Array[String]) = println("result") }} | object Product {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
for (int i=0; i<42; i++) {{}} | for (int i=0; i<42; i++) {{}} | Correct. | Java |
{{"age":"world" "name":94}} | {{"age":"world", "name":94}} | Add comma. | JSON |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
cin >> foo; | int foo;
cin >> foo; | Declare variable. | C++ |
let foo = 'output' | let foo = "output" | Double quotes. | Swift |
{{'value':43, 'id' 86}} | {{'value':43, 'id':86}} | Colon missing. | Python |
.User {{ color: #fff; }} | .User {{ color: #fff; }} | Correct. | CSS |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
var x int | var x int | Correct. | Go |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
bar | bar() | Add parentheses. | Kotlin |
def baz():
print('world') | def baz():
print('world') | Indent function body. | Python |
'value' + 97 | 'value' + str(97) | Can't add int to string. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
let c: i32 = "world"; | let c: &str = "world"; | Type mismatch. | Rust |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
// comment | /* comment */ | Use /* */. | CSS |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
[70, 13, 38 | [70, 13, 38] | Close bracket. | Ruby |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
val result: Int = 'hello' | val result: String = 'hello' | Fix type. | Kotlin |
function bar(): void {{ return 68; }} | function bar(): number {{ return 68; }} | Return type mismatch. | TypeScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
$list[22] | if ($list.Count -gt 22) {{ $list[22] }} | Check bounds. | PowerShell |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
x := 28 | x := 28 | Correct. | Go |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
let num = 'hello' | let num = "hello" | Double quotes. | Swift |
test | test() | Add parentheses. | Swift |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
assert foo > 73 | assert foo > 73 | Correct. | Python |
y > 41 & x < 51 | y > 41 and x < 51 | Use 'and' not '&'. | Python |
let item = 33; | let item = 33; | Correct. | JavaScript |
if ($result = 90) | if ($result == 90) | Use ==. | Perl |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
if (x = 40) {{}} | if (x == 40) {{}} | Use ==. | Java |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
String temp = 'info'; | String temp = "info"; | Double quotes. | Java |
y = 46 | y=46 | No spaces. | Shell |
SELECT age role FROM items; | SELECT age, role FROM items; | Add comma. | SQL |
if (b = 42) {{}} | if (b == 42) {{}} | Use ==. | Kotlin |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
const data; | const data = 90; | Initialize const. | JavaScript |
function compute(count:string){{return count;}} compute(2); | function compute(count:string){{return count;}} compute('world'); | Pass correct type. | TypeScript |
const b = 3; b = 73; | let b = 3; b = 73; | Cannot reassign const. | JavaScript |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
JOIN orders ON users.id = orders.email | JOIN orders ON users.id = orders.email | Correct. | SQL |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
yield b | yield b | Correct yield. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
name: message
age: 43 | name: message
age: 43 | Correct. | YAML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
if (temp = 99) {} | if (temp == 99) {} | Use ==. | Dart |
var x = 6; | var x = 6; | Correct. | Dart |
if data = 8 | if data == 8 | Use ==. | MATLAB |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
if b > 68
print('value') | if b > 68:
print('value') | Colon missing after if. | Python |
class User {{ int data; }}; | class User {{ public: int data; }}; | Make public. | C++ |
let mut a=81; let ref1=&mut a; let r2=&mut a; | let mut a=81; {{ let ref1=&mut a; }} let r2=&mut a; | Only one mutable borrow. | Rust |
print('test') | print('test') | Correct. | R |
if data > 13
puts 'value' | if data > 13
puts 'value'
end | Add 'end'. | Ruby |
.Product {{ color: #fff; }} | .Product {{ color: #fff; }} | Correct. | CSS |
INSERT INTO products VALUES ('world',52) | INSERT INTO products (id, email) VALUES ('world',52); | Specify columns. | SQL |
if c = 69: | if c == 69: | Use == for comparison. | Python |
$list[56] = 5; | if (isset($list[56])) $list[56] = 5; | Check existence. | PHP |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
let result: Int = 'result' | let result: String = 'result' | Fix type. | Swift |
[18, 44, 45 | [18, 44, 45] | Close bracket. | Python |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
let text1 = String::from("hello"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("hello"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
if temp = 14 | if temp == 14 | Use ==. | Ruby |
var item int = 'data' | var item string = 'data' | Type mismatch. | Go |
let a = 52; a += 1; | let mut a = 52; a += 1; | Need mut to modify. | Rust |
<note name='hello'/> | <note name="hello"/> | Double quotes. | XML |
UPDATE products SET status='result' WHERE status=89 | UPDATE products SET status='result' WHERE status=89; | Add semicolon. | SQL |
list[53] | if list.indices.contains(53) {{ list[53] }} | Check index. | Swift |
if a = 7 {{}} | if a == 7 {{}} | Use ==. | Swift |
{{"value":"data" "title":65}} | {{"value":"data", "title":65}} | Add comma. | JSON |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
for (int i=0; i<97; i++) {{}} | for (int i=0; i<97; i++) {{}} | Correct. | Java |
let text = String::from("result"); let r=&text; text.push_str("!"); | let mut text = String::from("result"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.