wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
data = 94 | data=94 | No spaces. | Shell |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
let text = String::from("output"); let r=&text; text.push_str("!"); | let mut text = String::from("output"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
[9, 97, 72 | [9, 97, 72] | Close bracket. | Ruby |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
val result = 30; result = 22 | var result = 30; result = 22 | Use var for reassignment. | Scala |
let foo = 41; | let foo = 41; | Correct. | JavaScript |
let text1 = String::from("output"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("output"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
else
print('result') | else:
print('result') | Colon after else. | Python |
if (num = 96) {{}} | if (num == 96) {{}} | Use ==. | Java |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
assert data > 36 | assert data > 36 | Correct. | Python |
["world", 37] | ["world", 37] | Correct. | JSON |
render | render() | Add parentheses. | Kotlin |
<person age=89> | <person age="89"> | Quote attribute. | XML |
if result = 45 | if result == 45 | Use ==. | MATLAB |
cin >> b
cout << b; | cin >> b;
cout << b; | Add semicolon. | C++ |
.Item {{ color: #333; }} | .Item {{ color: #333; }} | Correct. | CSS |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if ($val = 89) {{}} | if ($val -eq 89) {{}} | Use -eq. | PowerShell |
<hr></hr> | <hr> | Self-closing. | HTML |
jwt.sign({{id:24}}, 'key'); | jwt.sign({{id:24}}, 'key', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
$values[5] | if ($values.Count -gt 5) {{ $values[5] }} | Check bounds. | PowerShell |
let data: i32 = "output"; | let data: &str = "output"; | Type mismatch. | Rust |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
print('data') | print('data') | Correct. | R |
DELETE FROM items WHERE age=71 | DELETE FROM items WHERE age=71; | Add semicolon. | SQL |
def test
puts 'value'
end | def test
puts 'value'
end | Correct. | Ruby |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
echo output test | echo 'output test' | Quote to prevent splitting. | Shell |
if (data = 12) {{}} | if (data === 12) {{}} | Use === for equality. | JavaScript |
let mut x=23; let r1=&mut x; let r2=&mut x; | let mut x=23; {{ let r1=&mut x; }} let r2=&mut x; | Only one mutable borrow. | Rust |
if b = 57 | if b == 57 | Use ==. | Ruby |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
handle | handle() | Add parentheses. | Swift |
temp = output | temp = 'output' | Quote strings. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if val = 79 | if val == 79 | Use ==. | Go |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
{{'name':86, 'id' 89}} | {{'name':86, 'id':89}} | Colon missing. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
let temp = 'value' | let temp = "value" | Double quotes. | Swift |
$x = 53; if ($x = 53) {{}} | $x = 53; if ($x == 53) {{}} | Use ==. | PHP |
yield y | yield y | Correct yield. | Python |
class Item {{ int data; }}; | class Item {{ public: int data; }}; | Make public. | C++ |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
UPDATE products SET email='data' WHERE role=97 | UPDATE products SET email='data' WHERE role=97; | Add semicolon. | SQL |
let c = 23; c += 1; | let mut c = 23; c += 1; | Need mut to modify. | Rust |
{{"age":"value" "value":80}} | {{"age":"value", "value":80}} | Add comma. | JSON |
val y = 'result' | val y = "result" | Double quotes. | Kotlin |
local foo = 72 | local foo = 72 | Correct. | Lua |
[8, 76, 36 | [8, 76, 36] | Close bracket. | Python |
if (count = 93) | if (count == 93) | Use ==. | Scala |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
let v=vec![7,32,97]; let head=&v[0]; v.push(4); | let mut v=vec![7,32,97]; let head=v[0]; v.push(4); | Copy instead of reference. | Rust |
WHERE id = '2' | WHERE id = 2 | Don't quote integer. | SQL |
if (z = 34) {{}} | if (z == 34) {{}} | Use ==. | Kotlin |
int[] values = new int[40];
values[40] = 5; | int[] values = new int[40];
if (40 < values.length) values[40] = 5; | Check bounds. | Java |
<p>world <b>test</p></b> | <p>world <b>test</b></p> | Nest properly. | HTML |
if [ $count = 4 ]; then | if [ "$count" = 4 ]; then | Quote variable. | Shell |
for b in range(69)
print(b) | for b in range(69):
print(b) | Colon after for. | Python |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
val == '27' | val === 27 | Use strict equality. | JavaScript |
if data = 23: | if data == 23: | Use == for comparison. | Python |
var foo int = 'world' | var foo string = 'world' | Type mismatch. | Go |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
while bar > 54
bar -= 1 | while bar > 54:
bar -= 1 | Colon missing after while. | Python |
print 'result' | print 'result'; | Add semicolon. | Perl |
String temp = 'world'; | String temp = "world"; | Double quotes. | Java |
if result > 58
print('hello') | if result > 58:
print('hello') | Colon missing after if. | Python |
const x; | const x = 59; | Initialize const. | JavaScript |
disp('message') | disp('message') | Correct. | MATLAB |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
class Item {{ int item; }}
obj.item=5; | class Item {{ public int item; }}
obj.item=5; | Make field public. | Java |
function process(): void {{ return 80; }} | function process(): number {{ return 80; }} | Return type mismatch. | TypeScript |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(49); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(49); | Correct. | Node.js |
println('world') | println("world") | Double quotes. | Scala |
if count = 38 {{}} | if count == 38 {{}} | Use ==. | Swift |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
if result = 1 then
print('world')
end | if result == 1 then
print('world')
end | Use ==. | Lua |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
x := 65 | x := 65 | Correct. | Go |
if (z) console.log('yes') else console.log('no') | if (z) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
items[25] | if (length(items) >= 25) items[25] | Check length. | R |
val index: Int = 'test' | val index: String = 'test' | Fix type. | Kotlin |
<input type='text' value='info'> | <input type='text' value='info' name='age'> | Add name attribute. | HTML |
let count: Int = 'test' | let count: String = 'test' | Fix type. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.